Search notes:

Software design patterns

A pattern provides a working solution to a common problem
The Gang of Four (Gof) established 23 well known design patterns.

Types

Three types of patterns. (Note: Interface, needed for encapsulation, decoupling the clients from the interface realizationis, a non standard pattern)

Creational

  • Abstract factory
  • Builder: Separate the construction of a complex object from its representation
  • Factory method: might be considered a simplified Builder.
  • Prototype
  • Singleton: Ensure that a class has only one instance.

Structural

  • Adapter: Converts one interface to another so that it matches what a client expects (for example when talking to legacy backend systems).
  • Bridge: (Not to be confused with the Adapter pattern)
  • Composite
  • Decorator: Add behaviour to an object (possibly a Facade) so as to enhance it. (Aspect oriented programming)
  • Facade: Provides a simplified interface. decouples independent classes, and more important, decreases (makes the interface more coarse grained) the granularity
  • Flyweight
  • Proxy: A class that controls access to another.

Behavioral

  • Chain of responsibility
  • Command: Represent an action as an object.
  • Interpreter
  • Iterator
  • Mediator
  • Memento
  • Observer: allows for concurrent operations. The observer just waits for the observable to emit values.
  • State
  • Strategy: Encapsulate a family of related algorithms.
  • Template method
  • Visitor

VS

Adapter vs Bridge

Adapter makes things work after they're designed; Bridge makes them work before they are.
GoF, p219

Adapter vs Decorator

A Decorator typically adds functionality to a wrapped object: logging, encryption, formatting etc.

See also

C. Alexander: A pattern language

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759562007, '216.73.216.149', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/Software-design/patterns/index(93): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78