Strategy defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently fromclients that use it..
Decorator (aka. Wrapper) allows behavior to be added to an individual object, either statically or dynamically, without affecting the behavior of other objects from the same class.
Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.
Singleton (aka. Wrapper) allows behavior to be added to an individual object, either statically or dynamically, without affecting the behavior of other objects from the same class.
Factory Method (aka. Virtual Constructor) defines an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.
Abstract Factory (aka. Kit) provides an interface for creating families of related or dependent objects without specifying their concrete classes.
Learning and writing Swift code is kind of fun! The new Apple language, Swift, extends Objective-C not only from the horizontal (like clean code strcuture, adding support to generics, etc.), but also from the vertical (like introducing more powerful enumeration and strcuture, using optional to deal with “nil”, etc.). In this series of “Design Patterns […]