Chapter 6 - Composition Flashcards
1
Q
object composition
A
- one object stores a reference to one or more objects
- an object composed of elements is the aggregate
2
Q
GOD CLASS antipattern
A
unmanageable class that knows everything and does everything
3
Q
COMPOSITE design pattern
A
- composite class that implements the interface contains an aggregate of that interface -> it can store other classes that implement that interface
- two ways to specify which instances of the interface form the aggregate:
1. add method in composite class
2. initialize through constructor in composite class
4
Q
sequence diagrams
A
- model the dynamic perspective of a software system
5
Q
DECORATOR design pattern
A
- when we want to decorate some object with additional features while being able to treat the decorated object like any other object of the undecorated type
- Decorator class implements the interface and contains an aggregate of instances of that interface
- the field that stores a reference to the decorated object is final and initialized in the constructor
6
Q
Polymorphic copying
A
- to make copies of objects without knowing their concrete types
- add a copy() method to the interface
7
Q
covariant return type
A
the return type of an implementing method can be more specific than the return type of the corresponding interface method it implements
8
Q
PROTOTYPE design pattern
A
- relying on a polymorphic copying mechanism and create new instances of an object of interest by copying a prototype object
- when you need to create objects whose type may not be known at compile time
- use dependency injection to inject an object into a class via its constructor
9
Q
COMMAND design pattern
A
provides a recognizable way to manage abstractions that represent commands
10
Q
law of demeter
A
a method should only access:
- the instance variables of its implicit parameter
- arguments passed to the method
- any new object created within the method
- globally available objects