Shane-oo / Head-First-Design-Patterns

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Object-oriented programing and UML terminology.

  1. A House is a building (inheritance);
  2. A House has a Room (composition);
  3. A House has an occupant (aggregation)
  4. A House uses an internet provider (association)

The difference between (2) and (3) is subtle yet important to differentiate. Together they are forms of association. What's the difference? Composition implies the child object cannot live out of the context of the parent (destroy the house and rooms disappear) whereas aggregation implies the child can exist on its own (destroy the house and the occupant goes elsewhere).

The Strategy Pattern

The Strategy Pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently of clients that use it.

The Observer Pattern

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 update automatically

The Decorator Pattern

The Decorator Patter attaches additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.

About


Languages

Language:Java 100.0%