Object Oriented Programming Resources/Head First Design Pattern Recaps

From srakrn | Wiki
Revision as of 14:54, 26 January 2022 by Srakrn (talk | contribs)
(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)
  • Depend upon abstractions. Do not depend upon concrete classes. (4/139)

Patterns (by order)

  1. 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.
  2. 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.
  3. The Decorator Pattern attaches additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.
  4. 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.
    1. The Abstract Factory Pattern provides an interface for creating families of related or dependent objects without specifying their concrete classes.