Name/C++
codes
|
UML
diagrams |
Explaination
|
- A simple class Base
|
|
类由矩形
框来表示 |
- Class with attribute (property) and operation
(method)
class Base { public: void fun(); private: int _x; }
|
|
|
|
- Generalization
class Base{}; class A:public Base{}; class B:public Base{}; class C:public Base{};
|
|
|
空心的三
角表
示继承关系 (泛化)
Implementing generalization: inheritance
|
- Aggregation
class A{...}; class B { A* theA; };
|
|

|
箭头表示
一种关系,箭头另一边有一个菱形(空心)表示聚合
(aggregation),聚合的意义表示has-a关系。 |
- Composition
class A{...}; class B { A theA; };
|
A会随着B的创建而创建,随B的消亡而消亡。
|

|
菱形为实
心的,它代表了一种更为坚固的关系——组合
(composition)。组合表示的关系也是has-a,不过在这里,A的生命期受B控制。
|
- Association: class A and class B are
associated if
- an object of A sends a message to an object of B,
- an object of A create an object of B,
- an object of A has an attribute whose values are
objects of B or collections of B,
- an object of A receives a message with an object
of B as an argument.
class
A{...};
class B
{
void fun(A params);
}; |
A被修改,那么类B会受到影响。
|

|
这里B与
A的关系只是一种依赖关系(Association)。这种关系表明,如果类A被修改,那么类B会受到影响。 |
- Squence diagrams
class circle { public: void fillcolor() { // ... }; void draw() { fillcolor(); }; };
class window { public: void drawcircle() { _circle.draw(); }; private: circle _circle; }; 对于下面的调用:
window wnd;
wnd.drawcircle();
对应的顺序图为:
|
|

|
图中上方
的方块表示参与的对象,垂直的虚线表示对象的生命线,方框表示激活,其中箭头表示了一个调用消息(也可以有回送return),如果是异步的消
息,则用半箭头表示,其中draw表示了一个自调用(self call) |

|
Application to PDEs
|
|