PHP特性的UML表示 [英] UML representation of PHP trait
问题描述
我正在使用Symfony2/Doctrine创建项目,并尝试实现特征. 到目前为止,在小型试用版上没有问题,但是在深入复杂项目之前,我通常会先做UML类图和序列图.
I'm creating projects with Symfony2/Doctrine and try to implement traits. So far no problem on small tryouts, but I usually do UML class and sequence diagrams before deep in complex projects.
什么是用来象征PHP特性的UML设计对象,据我所知,行为可以被看作是?有什么清洁的方法吗?
What is the UML design object(s) to be used to symbolize PHP traits, which can be seen as far as I know as behaviors? Is ther any clean way to do so?
非常感谢您的回答!
尼古拉斯
推荐答案
PHP
Trait
基本上是 UML类模板通过 UML通用化关系连接到所用的类 a>使用多重继承表示法
PHP
Trait
is basically UML Abstract Class or UML Class Template connected to the used-in class with the UML Generalization Relationship utilizing the multiple inheritance notation
另请参阅:
从PHP
5.4.0开始,PHP
实现了称为Traits
的代码重用方法.
As of PHP
5.4.0, PHP
implements a method of code reuse called Traits
.
Traits
是一种在单继承语言(例如PHP
)中重用代码的机制. Trait
旨在通过使开发人员能够在生活在不同类层次结构中的多个独立类中自由重用方法集,从而减少单一继承的某些限制.定义Traits
和类的组合的语义可以降低复杂性,并避免与多重继承和Mixins
相关的典型问题.
Traits
are a mechanism for code reuse in single inheritance languages such as PHP
. A Trait
is intended to reduce some limitations of single inheritance by enabling a developer to reuse sets of methods freely in several independent classes living in different class hierarchies. The semantics of the combination of Traits
and classes is defined in a way which reduces complexity, and avoids the typical problems associated with multiple inheritance and Mixins
.
A Trait
与类相似,但仅用于以细粒度且一致的方式对功能进行分组. 无法单独实例化.它是传统继承的补充,可以使行为的横向组合成为可能.也就是说,类成员的应用无需继承
A Trait
is similar to a class, but only intended to group functionality in a fine-grained and consistent way. It is not possible to instantiate a Trait
on its own. It is an addition to traditional inheritance and enables horizontal composition of behavior; that is, the application of class members without requiring inheritance
这篇关于PHP特性的UML表示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!