Design Pattern

Design Pattern

a design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. A design pattern is not a finished design that can be transformed directly into source or machine code. It is a description or template for how to solve a problem that can be used in many different situations.  
Object-oriented design patterns typically show relationships and interactions between classes or objects, without specifying the final application classes or objects that are involved. Patterns that imply object-orientation or more generally mutable state, are not as applicable in functional programming languages.

Creational Design Pattern
Singleton: Ensure a class has only one instance, and provide a global point of access to it.
Factory Method: create a related type polymorphically
Prototype: allows polymorphic duplication of heterogeneous types

Behavioral Design Pattern
Visitor: Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates.
Observer: tell registered observers when state changes
Memento: packages up object state without violating encapsulation
Iterator: access elements sequentially no matter how stored

Structural Design Pattern
Adapter: converts an interface you have into one you want

Comments

Popular posts from this blog

Sudoku

Longest prefix matching - trie

Climbing Stairs