0x380 Design Pattern

Foundations

Basic Concepts

SOLID

  • S: Single-responsiblity principle.
  • O: Open-closed principle.
  • L: Liskov substitution principle.
  • I: Interface segregation principle.
  • D: Dependency Inversion Principle

Composition vs Aggregation

Both are Association

  • Composition: A “owns” B
  • Aggregation: A “uses” B

Catalogs

Facade

  • hide complex logic by providing an clean interface (just a wrapper?)

Iterator

  • Iterator provides a way to access an aggregate object without exposing internal representations
  • Each Iterator is responsible to maintain the current element
  • Each iterator is associated with its aggregate, so aggregate object should implement Aggregate (Iterable) interface which supports the createIterator

Reference

[1] Gamma, Erich. Design patterns: elements of reusable object-oriented software. Pearson Education India, 1995.