OOAD – Object Oriented Analysis and Design
Objects have state and behavior; state of object is shown by the member variables of the object; behavior of objects is shown by the methods, the methods access, manipulate the member variables of the objects. Methods of the objects are called at the time of interaction. Deciding which method goes to which object and how the interaction between objects takes place is a complicated process. Mastering OOAD requires understanding of large set of principles; knowledge about design Patterns, lots of practices, examples are of great help.
Software design is done based on the responsibilities, roles and collaborations of the software objects. Responsibility is a contract or obligation of a class. Responsibilities are assigned to object during object design. Responsibilities are of two types: doing and knowing.
Object-Oriented programming has been more than four decades old. Several programmers developed software using OOP languages like Smalltalk, C++,Lisp and gained lots of experience about programming with objects. Some of those experienced OO developers developed a repertoire of problems and solutions that were faced quite frequently in almost all software development process. That repertoire of problems and solutions is Design Patterns. The design patterns have name, problem statement and the solution statement.
In 1994, massive-selling and hugely influential book: Design Patterns written by Gamma, Helm, Johnson and Vlissides (Gang of Four (GoF)) was published. This book considered 23 design patterns for Object-Oriented software design. Those 23 design patterns are also known as the Gang of Four (GoF) design patterns.
The GRASP patterns are not new patterns; they are just simplification of existing patterns/principles. GRASP defines nine basic OO design principles. GRASP is about figuring out the responsibilities and assigning responsibilities to the objects. GoF is for more advanced design ideas. Design patterns can be used during modeling and coding.
|Problem:||Who creates an object of class A?|
|Solution:||Class B will create object of class A if any one of the following is true:
|Problem:||How to know which object has what responsibility or on the basis of what responsibilities are assigned to objects?|
|Solution:||Assign responsibility to that object which has all the information required to fulfill that responsibility.|
|Problem:||How to reduce the impact of change in one object on other objects?|
|Solution:||Assign responsibilities to objects in such a way that reduces coupling (dependencies) between the objects. That is, to perform responsibility by an object, it should be able to perform without minimum help from other objects.|
|Problem:||Which first object beyond the UI layer will receive and control a system operation? How to make UI focused on its job of taking/showing data to the users only?|
|Solution:||Consider object representing any one of the following options:
|Problem:||How to create focused, understandable and manageable objects that support Low Coupling?|
|Solution:||Assign only those responsibilities to the objects which are of their concern and they should do, don't assign unnecessary responsibilities to the object which they can't do independently.|
|Problem:||How to handle alternatives situations based on type?|
|Solution:||Assign responsibilities for behavior using polymorphic operations.|
|Problem:||Which object should be assigned the responsibility, when low coupling and high cohesion principles are not to be violated?|
|Solution:||Create an artificial class, not part of the domain concept, with highly cohesive set of responsibilities. Fabricate an object.|
|Problem:||How to avoid direct coupling (dependency) between two or more objects?|
|Solution:||Assign responsibility to an intermediate object to mediate between other objects or services to create low coupling between those objects.|
|Problem:||How design objects so that the variations or changes in these objects do not have an unwanted impact on other objects?|
|Solution:||Create stable interface around the varying features or functions of the objects.|