Saturday, May 1, 2010

Design Pattern basic diagrams

It'd be much helpful to learn the basic diagram notations before we jump to the actual design patterns. There are three types of notations to represent the ideas of patterns:

  1. Class Diagram: To represent static relationships with the other classes.
  2. Object Diagram: To represent object structure at run-time.
  3. Interaction Diagram: To show flow of requests between objects. 

Let's start with the Class diagram:

 Let's try to understand all the the above class diagrams in figure A,B,C,D,E and F.
  • Fig .A. Names in italic represents an abstract class or abstract method.
  • Fig. B. A concrete class name, its data member and methods.
  • Fig. C. Participant Client class is also like any other normal class if it has any responsibility  in the pattern.
  • Fig. D. Implicit Client class - If client class has no direct responsibility in the pattern.
  • Fig. E. Drawing class is an aggregation of Shape classes(Abstract), which has been  inherited by LineShape class, and the LineShape is acquainted with Color class i..e it keeps the reference of Color class, whereas LineShape class itself can be instantiated by the CreationTool class.
  • Fig.F. To show the pseudocode implementation for any operation in the class.

Object Diagrams:

Here in the object diagram we can see how an object aDrawing is keeping the reference of another objects(aCircle, aLine,...) at runtime.

Interaction Diagram:
In the interaction diagram, the vertical solid line represents the lifetime of an object, whereas the vertical rectangle represents active state of an object and the dotted line is to show that the object has not been created yet.

We'll see the more details in the next section.

Thanks for the reading.

No comments: