Patterns Flashcards
Factory
Creational pattern.
Creates objects based on some input data.
Abstract Factory
Creational pattern.
Creates factories based on some input data.
Singleton
Creational pattern.
Object with a single instance, available via static method.
Builder
Creational pattern. Builds complex item in steps with builder class and helper methods.
Prototype
Creational pattern.
Object is created by cloning existing object (to avoid requesting data if it is costly).
Adapter / Wrapper
Structural pattern.
Object is put inside other object and its methods mapped to the required methods.
Bridge
Structural pattern.
Multiple classes implement same interface, acting thus as bridge to different realisations.
Filter (Criteria)
Structural pattern.
Object that filters some data and can be combined with objects which filter the same type of data.
Composite
Structural pattern.
Used when we need to treat heirarchy of objects as one object.
Decorator
Structural pattern.
Allows for the dynamic wrapping of objects in order to modify their existing responsibilities and behaviors.
Facade
Structural pattern.
Hides complexity of some code behind simplified interface.
Flyweight
Structural pattern.
Reusing existing objects as much as possible to lower memory footprint.
Proxy
Structural pattern.
Controls and manages access to some other object.
Chain of responsibility
Behavioral pattern.
Gives more than one object an opportunity to handle a request by linking receiving objects together.
Command
Behavioral pattern.
Command is sent in a form of object to the other object which can execute it.
Interpreter
Behavioral pattern.
Describes how one type of data should be converted to some other related type.
Iterator
Behavioral pattern.
Provides access to the collection without any need to know underlying implementation.
Mediator
Behavioral pattern.
Object acts as a central hub which manages communication of a group of objects.
Memento
Behavioral pattern.
Saving state of an object externally to be restored later.
Observer
Behavioral pattern.
Observable object provides ways for Observers to subscribe to data it emits.
State
Behavioral pattern.
Behaviour of an object depends on its state.
Null
Behavioral pattern.
Special object which reflects a do nothing relationship.
Strategy
Behavioral pattern.
When object changes its behavior depending on external circumstances.
Template
Behavioral pattern. Subclasses override methods from class to provide different behaviours.
Visitor
Behavioral pattern.
Group of objects accept visitor object which describes some logic operations using them, thus externalizing logic.
Factory method
Creational pattern.
Provides a method to create an instance of the class.
Dependency injection
Creational pattern.
Class does not create classes it needs for working recieving them from outside instead.
Lazy initiation
Creational pattern.
Object is only initiated when it is actually needed.
Multiton
Creational pattern. Ensures class has only named instances and provides global point of access to get them.
Object pool
Creational pattern.
Avoid expensive aquisition and release of resources by recycling objects which are no longer in use.