Department of Computer Science & Engineering Cs6502-Object Oriented Analysis and Design Unit-Ii Design Patterns
Department of Computer Science & Engineering Cs6502-Object Oriented Analysis and Design Unit-Ii Design Patterns
Department of Computer Science & Engineering Cs6502-Object Oriented Analysis and Design Unit-Ii Design Patterns
UNIT-II
DESIGN PATTERNS
GRASP: Designing objects with responsibilities – Creator – Information expert – Low Coupling – High
Cohesion – Controller - Design Patterns – creational - factory method - structural – Bridge – Adapter -
behavioral – Strategy – observer.
PART- A
1. How to Choosing the Initial Domain Object?
Choose as an initial domain object a class at or near the root of the containment or aggregation
hierarchy of domain objects. This may be a facade controller, such as Register, or some other
object considered to contain all or most other objects, such as a Store
.
2. How to Connecting the UI Layer to the Domain Layer?
• An initializing routine (for example, a Java main method) creates both a UI and a domain
object, and passes the domain object to the UI.
• A UI object retrieves the domain object from a well-known source, such as a factory object that
is responsible for creating domain objects.
5. Define patterns.
A pattern is a named problem/solution pair that can be applied in new context, with advice on
how to apply it in novel situations and discussion of its trade-offs.
8. Who is creator?
Solution Assign class B the responsibility to create an instance of class A if one or more of the
following is true:
. B aggregates an object.
. B contains an object.
. B records instances of objects.
. B closely uses objects.
. B has the initializing data that will be passed to A when it is created (thus B is an Expert with
respect to creating A).
B is a creator of an object.
If more than one option applies, prefer a class B which aggregates or contains class A.
9. List out some scenarios that illustrate varying degrees of functional cohesion.
-Very low cohesion
-low cohesion
-High cohesion
-Moderate cohesion
- Use the same controller class for all system events in the same use case scenario.
-Informally, a session is an instance of a conversation with an actor.
-Sessions can be of any length, but are often organized in terms of use cases (use case sessions).
PART- B
1. Explain Grasp: designing objects with responsibilities.
-Responsibilities and Methods
-Responsibilities and Interaction Diagrams
-Patterns