Last active
January 21, 2016 18:13
-
-
Save vigneshr89/4ee0f437ad7c549dea79 to your computer and use it in GitHub Desktop.
Design patterns in one lines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Design patterns | |
Behavioural: Deals with communication of objects | |
Chain-Of-Responsibility - Think of UIResponder class | |
Command pattern - NSInvocation class. Support undoable operations | |
Interpreter - language parsing. Think of expression evaluation | |
Iterator - NSEnumerator; A unified interface for interating a collection. | |
Mediator - Think of a translator's role in multi lingual people communication. | |
Memento - Think of a storing in the middle of a game and restore it. | |
observer - KVO. | |
State - Think of a premium and basic user on file sharing site. | |
(The data such as speed , download limit, etc changes based on a condition. ) | |
Creation : Deals with object creation | |
Abstract Factory - Returns a factory method to create objects. | |
Factory Method - Think of NSArray init methods. | |
Singleton - One object to rule them all. | |
Builder - Create object based on a builder passed. | |
( Useful to when object creation needs some order or particular algorithm ) | |
Prototype - Object with clonable interface. | |
Structural : Deals with the object relations | |
Adapter - Need them when legacy code has to be reused with a modern interface. | |
Bridge - Prefer composition over unnecessary inheritance. Remember RedRectangle is silly. | |
Composite - Think of a directory. It can contain sub directories and files. | |
Decorator - Embellish an object using composition | |
Protection proxy - Protect an object using composition | |
Virtual proxy - On demand initialization using composition. | |
Facade - Simple interface to hide structural complexity. | |
Implemetation of all these patterns in swift can be found here: https://github.com/ochococo/Design-Patterns-In-Swift | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment