Skip to content

Latest commit

 

History

History
37 lines (28 loc) · 2.48 KB

README.md

File metadata and controls

37 lines (28 loc) · 2.48 KB

Design Patterns 101

This repository is a collection of design patterns in object-oriented programming.

The repository is a work in progress and will be updated as I learn more about design patterns.

OO basics

  • Abstraction
  • Encapsulation
  • Polymorphism
  • Inheritance

OO Principles

  1. Encapsulate what varies
  2. Favor composition over inheritance
  3. Program to an interface, not an implementation
  4. Strive for loosely coupled designs between objects that interact
  5. Classes should be open for extension but closed for modification

Design Patterns

  1. Strategy Pattern

    • Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it. Strategy Pattern Image
  2. Observer Pattern

    • Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. Observer Pattern Image
  3. Decorator Pattern

    • Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality. Decorator Pattern Image
  4. Factory Pattern

    • Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses. Factory Pattern Image