Class Diagram

Class Diagram depicts the structural view.


Another name for generalization is Inheritance. This is represented by a triangle with a line in the middle coming out.

Generalization in Class Diagram


There are 2 types of associations in class diagram. One is called Composition and the other is called aggregation.

If one thing is totally dependent on other thing then it is called composition and it is represented by diamond filled with black color.

Composition in Class Diagram

If one thing is not totally dependent on other thing then it is called Aggregation. It is represented by a hollow diamond.

Aggregation in Class Diagram

Access Modifiers

  • Private is represented by –
  • Public is represented by +
  • Protected is represented by #

Compartments of Class

There are 3 compartments of a class in class diagram. In first compartment, name of the class is written. In second compartment, attributes of the class are written. In third compartment, methods of the class are written.

How to represent Attribute?

    attribute-name : Type = Initial-value

For example,
minSalary : int = 10000

How to represent Operations?

    operation-name (parameter-list) : return-type

For example, drawAmount(amount:int=500):int
Here drawAmount operation returns balance with return type of int.