Online-Academy

Look, Read, Understand, Apply

Menu

OOAD - Object Oriented Analysis and Design

Class Diagram

Class Diagram

Class diagram shows the static view of the application or system, it is used for visualizing, describing, documenting and constructing executable code of the software system. It is used in modeling of the object-oriented systems; it can be mapped directly with the object-oriented programming languages. The attributes and methods of the class and relationship between classes are shown. Class diagram forms basis of the component and deployment diagram.

Class diagram consists of classes and their relationships. Application is developed to serve user; application has features which users use; application is integration of different objects. Objects with similar features belong to same class. Classes of the application are figured about by analyzing the requirements of the users; the requirements of users from the application are collected during the requirement collection phase of software (application) development. One of the methods to find classes is noun phrase analysis of the requirements text collected from the users of the software.

Purpose of the Class Diagrams

  • To analyze and design the static view of a software
  • to describe responsibilities of the object of the system
  • for forward and reverse engineering

In the class diagram, classes are represented by the rectangle with three parts: in the first (top) part, name of the class is written, in the second (middle) part, attributes of the class are written, in the third (bottom) part, methods of the class are written. The relationship or association between the classes are shown with a straight line. Role of the class in the relationship can be also shown. The multiplicity (like 1 to 1, 1 to many, many to many) between the classes are also show in the diagram; multiplicity defines the number of objects involved in the relationship between the objects.

There are three types of relationships that can exist between the classes:

  • Association: for example, customer purchases product; here purchases is association between customer class and product class. Customers play role of purchaser in the relationship; a customer can purchase one or more products. So, the multiplicity between customer and product is one to many.
  • Inheritance (Super Class Sub class): There are at least two classes one is called base (super) class and other is derived (sub) class. The properties of the base class is inherited (acquired) by the derived class. That is, the derived classes will get the properties of the base class, the derived classes don’t have to redefine those properties in their classes. An arrow with hollow triangle is used to show the inheritance relationship. Inheritance shows the is-a relationship between the objects.
  • Aggregation: An object can be composed of one or more other objects; relationship in which one object is formed by aggregating other objects is called aggregation relationship. In class diagram aggregation relationship is shown with a line with hollow diamond at one end. The aggregation shows the part-of relationship.