Skip to content

Instantly share code, notes, and snippets.

@belfie13
Last active September 8, 2022 19:10
Show Gist options
  • Save belfie13/03917c3e2b67738302a8a589e568e7de to your computer and use it in GitHub Desktop.
Save belfie13/03917c3e2b67738302a8a589e568e7de to your computer and use it in GitHub Desktop.

Behavioural

Chain of responsibility

  • pass a request down a chain of objs until one handles the request.
  • handler objs either handle or forward a request.

Creation

Abstract Factory

  • an interface for creating different groups of related or dependant objects.
interface «AbstractFactory» {
    public function createObjectA(): ClassA;
    public function createObjectB(): ClassB;
 }
  • eg. «ElementFactory» -> «DomElementFactory», «HtmlElementFactory»

Builder

  • an interface for a construction process to create different complex objects.
interface «Builder» {
    public function getComplexObject(): ClassC;
    public function buildObjectA();
    public function buildObjectB();
 }

Structures

Decorator

  • add responsibility to an obj dynamically
  • extend functionality of an obj

Terms

:dynamically: at run-time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment