Object Oriented Programming Resources/Head First Design Pattern Recaps

From srakrn | Wiki
Revision as of 14:18, 26 January 2022 by Srakrn (talk | contribs) (Created page with "== Design Principles == * Identify the aspects of your application that vary and separate them from what stays the same. (1/9) * Program to an interface, not an implementatio...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Design Principles

  • Identify the aspects of your application that vary and separate them from what stays the same. (1/9)
  • Program to an interface, not an implementation. (1/11)
  • Favor composition over inheritance. (1/23)
  • Strive for loosely coupled designs between objects that interact. (2/53)
  • Classes should be open for extension, but closed for modification. (3/86)

Patterns (by order)

  • 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.
  • 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.
  • The Decorator Pattern attaches additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.
  • The Factory Method Pattern defines an interface for creating an object, but lets subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.