In software engineering, a software design pattern is a general, reusable solution to a common problems within a given context in software design.
Fundamentally, the goal of object-oriented design patterns are aimed at creating software that's extensible and maintainable so that it can deal with change.
- Name
- Context (a.k.a. the situation)
- Problem
- Solution (usually, a class diagram will be helpful)
- Related patterns
- Abstraction
- Encapsulation
- Polymorphism
- Inheritance
- Favor composition over inheritance.
- Program to an interface (i.e. supertype), not an implementation
- Programming to an implementation:
Dog d = new Dog(); d.bark();
- Programming to an interface:
Animal animal = new Dog(); animal.makeSound();
- Programming to an implementation:
- Encapsulate what varies
- Here’s another way to think about this principle: take the parts that vary and encapsulate them, so that later you can alter or extend the parts that vary without affecting those that don’t.
- Strive for loosely coupled design
- Classes should be open for extension but closed for modification
- Depend on abstractions (not concrete implementations)
- Talk to friends, not strangers
- Don't call us, we'll call you (the Hollywood principle)
- A class should only have one reason to change
- Design Patterns Catalog
- Head first design patterns
- GoF Design Patterns Implemented in JavaScript
- Design Patterns in ES6
- Design Patterns with Examples in JavaScript
- Design Patterns for Humans
- Design patterns in modern JavaScript development
- Design Patterns Game
- Observer pattern lab: https://github.com/thoughtworks-jumpstart/observer-pattern-lab