58 lines
1.8 KiB
Org Mode
58 lines
1.8 KiB
Org Mode
* Head First Design Patterns
|
||
:PROPERTIES:
|
||
:NOTER_DOCUMENT: ../../../pdfs/bootcamp/Head First Design Patterns.pdf
|
||
:ID: dc9ece84-0b14-4afd-b25a-786cf1618996
|
||
:END:
|
||
** Chapter 1
|
||
:PROPERTIES:
|
||
:NOTER_PAGE: 36
|
||
:END:
|
||
*** Structural:
|
||
The Strategy Pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
|
||
|
||
- Encapsulate what varies
|
||
|
||
- Favor composition over inheritance
|
||
|
||
- Program to interfaces, not implementations
|
||
|
||
** Chapter 2
|
||
:PROPERTIES:
|
||
:NOTER_PAGE: 82
|
||
:END:
|
||
*** Observer:
|
||
The Observer Pattern defines a one-to-many dependency between objects so that when
|
||
one object changes state, all of its dependents are notified and updated automatically.
|
||
|
||
Subjects, or as we also know them, Observables, update Observers using a common
|
||
interface
|
||
|
||
Observers are loosely coupled in that the Observable knows nothing about them,
|
||
other than that they implement the Observer interface.
|
||
|
||
You can push or pull data from the Observable when using the pattern (pull is
|
||
considered more “correct”).
|
||
|
||
Don’t depend on a specific order of notification for your Observers.
|
||
|
||
Java has several implementations of the Observer Pattern, including the general
|
||
purpose java.util.Observable
|
||
|
||
- Strive for loosely coupled designs between objects that interact
|
||
** Notes for page 137
|
||
:PROPERTIES:
|
||
:NOTER_PAGE: 137
|
||
:END:
|
||
|
||
- Classes should be open for extension, but closed for modification.
|
||
** Notes for page 142
|
||
:PROPERTIES:
|
||
:NOTER_PAGE: 142
|
||
:END:
|
||
Notes for the decaroter pattern.
|
||
** Notes for page 143
|
||
:PROPERTIES:
|
||
:NOTER_PAGE: 143
|
||
:END:
|
||
Decorator pattern: The Decorator Pattern attaches additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.
|