Notes for different design patterns in programming. This aplies to almost any language but I am focusing on C# and .NET.
- Introduced by Robert C. Martin (aka: Uncle Bob)
See Projects with related names for a code example. I am keeping all code in one file on purpose. To keep projects in groups and keep things simple for demonstration.
-
Single Responsibility
- A single class should have one reason to change
-
Open-Closed Principle
- Open for extension closed for modification
- we shouldn't need to modify existing code. we can use inheritence, with interfaces
- in our code we get asked to add more filters on a products page. We are going to use the "Specification Pattern" (not gang of four but considered an enterprise pattern).
-
Liskov Substitution Principle
-
which describes the fundamental nature of data abstraction, and is used in type theory (see subtyping) and in object-oriented programming (see inheritance). Her work was recognized with the 2008 Turing Award, the highest distinction in computer science. (named after Barbara Liskov)
-
we should be able to substitute a base type for a sub type.
-
-
Interface Segregation Principle
-
Dependency Inversion Principle
- Builder
- Factories
a. Abstract Factory
b. Factory Method
- Prototype
- Singleton
- Adapter
- Bridge
- Composite
- Decorator
- Facade
- Flyweight
- Proxy
- Chain of Responsibility
- Command
- Interpreter
- Iterator
- Mediator
- Memento
- Null Object
- Observer
- State
- Strategy
- Template Method
- Visitor