Design Patterns In Real World Applications

Some assumptions are made that a reader is familiar with the underlying design pattern discussed.

This is not about how to implement a specific pattern, but an illustration where certain designs come in handy. My expertise lies in Python, so while this list should be language-agnostic, some Pythonic things may slip.

Creational Patterns

  1. Abstract Factory *
  2. Builder *
  3. Factory Method *
  4. Monostate
    • Same as Singleton examples, just implementation is slightly different.
  5. Singleton
    • External API that throttles max connections. | Force usage of single API instantiation.
  6. Prototype *

Behavioral Patterns

  1. Chain of Responsibility
    • Exceptions can be operated by numerous interfaces.
  2. Command
    • Job Queues | Passing jobs that can be executed by any machine.
  3. Interpreter *
  4. Iterator *
  5. Mediator
    • Mailing Lists & Chatrooms | Mediator decides how and what messages recipients should recieve.
  6. Memento
    • Undo Functionality | Snapshot of before and after action.
  7. Null Object *
  8. Observer *
  9. Null State *
  10. Strategy *
  11. State
    • Aka a "mode". Emails contain state of "sent", "unsent".
  12. Template Method *
  13. Visitor
    • Calculating taxes in different regions on sets of invoices would require many different variations of calculation logic. Implementing a visitor allows the logic to be decoupled from the invoices and line items.

Structural Patterns

  1. Adapter *
  2. Bridge *
  3. Composite *
  4. Decorator *
  5. Facade
    • Python's os.path | Simplify extensive upstream interface. Simplies split + indexing
  6. Flyweight *
  7. Proxy *

Credit