chapter 4 Flashcards
(41 cards)
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
what are the goals of a dp?
GRE
- reuse of designs
- evolution of sw
how can we achieve the goals of a dp?
by reducing dependencies among components
- program to interfaces not implementations
- favor obj composition not inheritance
- use delegation
what are elements of a dp?
NPC are Sus
- name
- problem
- consequence
- solution
____________ is an element of a dp, that describes when to apply a pattern?
problem
____________ is an element of a dp, that describes elements that make up the pattern, their r/n ship and responsibilities?
solution
____________ is an element of a dp, that describes results and the tradeoffs of applying the pattern?
consequence
explain what scope is in a dp
- describes what the pattern applies to
Example: - class patterns : focus on r/n ships b/n classes and subclasses
- obj patterns : focus on r/n ships b/n objs
what scope of dp deals with class inheritance?
class pattern