chapter 4 Flashcards
define a design pattern.
pattern is a general repeatable solution to commonly occurring problem in OO software design [ context ].
is a design pattern a finished design? why?
- its not a finished design that can be transformed into a code, but rather a template for how to solve a problem.
Example: - house blueprint
the book; The Gang of Four’s book was written based on the principles of _____________ ?
Christopher Alexander
what did the GoF’s book achieve?
initiated the concept of design patterns in software dev’t
according to the GoF, a design pattern should be based on which OO principles?
- program to an interface not an implementation
- favor object composition over inheritance
what are types of DP defined by the GoF?
- creational dp
- structural dp
- behavioral dp
describe creational dp
- creates objs in a manner suitable for the situation.
- deals with obj instantiation
- hides creation logic, instead of just using the new operator
describe a structural dp?
- deals with r/n ships b/n entities, to make it easier for them to work together
- concerned with classes and object composition
describe behavioral dp
- concerned with common communication patterns b/n objects
a factory method is a pattern catalog belonging to ____________ dp?
creational
an adapter is a pattern catalog belonging to ____________ dp?
structural
what are characteristics of a dp?
LV R
- levels - decomposition of patterns
- view points - description of patterns
- roles - “players” in pattern usage
what is the d/ce b/n static and dynamic viewpoints?
- static vp - describes class models [ building blocks ]
- dynamic vp - seq diagrams
what are the forms of a dp?
FDR
- delegation
- recursion
describe delegation dp form.
- a mechanism in w/c an obj delegates a req to another obj
- the other obj carries out the req on behalf of the original obj
describe recursion dp?
- a mechanism in w/c part of the pattern uses itself
Example: - GUIs where windows within windows are allowed