GRASP 2 Flashcards

1
Q

What problem does the Polymorphism pattern aim to resolve?

A

How to handle alternatives based on type?
 Fundamental theme in programs
 Adding new alternatives if using if-then-else or case-statement can require mods in many places
How to create pluggable software components?
 E.g. Client-Server relationship:
o How to replace Server component without affecting Client?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What solution does the Polymorphism pattern propose?

A

When related alternatives vary by type (class):
 use operations with the same interface
 to assign responsibilities for the behaviour
 to the types for which the behaviour varies.
Corollary:Don’t use conditionals to select the alternative.
Polymorphic: giving a single interface to entities of different types.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the contraindications of the Polymorphism pattern?

A

See contraindications for Protected Variations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What problem does the Pure Fabrication pattern aim to resolve?

A

Which object should have responsibility when solutions offered by (e.g.) Expert violate High Cohesion and Low Coupling?
Use domain objects in design to lower representational gap
Sometimes using only domain objects in design result in poor coupling, cohesion, or reuse

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What solution does the Pure Fabrication pattern propose?

A

Assign a highly cohesive set of responsibilities to a class not in the problem domain:
 Made up to support high cohesion, low coupling, and reuse.
 Fabrication of the imagination, for the purpose of ensuring that the design is very pure
 Name is also an English idiom for an intentional lie, something you do when desperate!
Pattern justifies increasing the representational gap.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the contraindications of the Pure Fabrication pattern?

A

 Sometimes overused as excuse to add new objects
 Can be driven by behavioural decomposition into functions, resulting in functions just being grouped into objects.
 Needs to be balanced with representational decomposition: assigning responsibilities to classes that have the required information
 Poorly applied, can adversely affect coupling

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What problem does the Indirection pattern aim to resolve?

A

 Where to assign a responsibility to avoid direct coupling between two (or more) s/w elements?
 How to de-couple objects so that low coupling is supported and reuse potential remains higher?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What solution does the Indirection pattern propose?

A

Assign the responsibility to an intermediate object to mediate between the other components or services so that they are not directly coupled.
 Intermediary creates an indirection between the other components.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the contraindications of the Indirection pattern?

A

 Higher complexity in design needs to be justified by the lower coupling
 Counter adage:
“Most problems in performance can be solved by removing another layer of indirection!”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What problem does the Protected Variations pattern aim to resolve?

A

How to design objects, subsystems, and systems so that the variations or instability in these elements does not have an undesirable impact on other elements?
Points of change include:
 variation point: variations in existing system or requirements (e.g. multiple tax calculators)
 evolution point: speculative variations that may arise in the future

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What solution does the Protected Variations pattern propose?

A

 Identify points of known or predicted variation or instability
 Assign responsibilities to create a stable interface*around them
*Interface: a means of access (not only a programming language interface or Java interface)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the contraindications of the Protected Variations pattern?

A

 Cost of speculative “future-proofing” at evolution points can outweigh the benefits
o It may be cheaper/easier to rework a simple “brittle” design
 Novice designers tend toward brittle designs
 Intermediate designers tend towards overly general and flexible designs (in ways not used)
 Expert designers get the balance right

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a pattern?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly