Now, we will learn about class diagram and what is the example for understanding this model.

In the class diagram we consider about Class Names, List of Attributes, and List of Methods. Also, we should give attention about implementor, helpers, and events. To make it be easy, we can start identify some class diagram (included the method) by using sequence diagram.

#Class Relationship

We have 4 items type of relationship in the class diagram

  1. Association (unidirection, bidirection, association class)
    uni direction means class A uses class B as object instancially. So, in the class A we can call all methods which exist in the class B.
    bidirection means class A uses class B, and also class B uses class B. The concept is similar to unidirection, class A can call every method which exist in the class B and the opposite.
    association class means one object class A and class B will be helped by one new class as a bridge. for example class customer and class car, the association class is class invoice which have several attribute such as date_transaction, cost_paid_by_customer, id_transaction etc). We will use this case in this article to be implemented by class diagram.
  2. Composition ( aggregation and containment)
    The concept (idea) of aggregation is when we have 2 classes ( class A and class B)  then diamond of relationship put in class B and the other edge in the class A,  it means if we delete the class B so the class A will be exist and can be used for another class.
    [A]——-<>[B]For containment, still using class A and B, but the diamond is filled by black color, the concept of containment is when we delete the class B, so the class A must be deleted also and can not be used for another class.
  3. Dependency, it mean using other class in the local method
    for example  in the class A we have method mA() which declare class B in the parameter or inside in the method.
    mA( B b){
    // Class B used in the parameter
    B objectB;
    // class B declared inside
  4. Generalization  (inheritance)
    The concept of inheritance is we recreate one class but have different attribute or different method. For example we have class Car, then we want to create another class which have new attribute, such as previouse owner, last_tax, etc. So, we can create class UsedCar generalization of class Car.
class diagram
class diagram
tool box class diagram
tool box class diagram

Folder class diagram