Design Patterns & Principles - Strategy Pattern
This is a part of a blogpost series listing the design principles and pattern definitions. The Strategy Pattern - defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets algorithm vary independently from clients that use it. Following are few principles adhered in this pattern Identify the aspect of your application that vary and separate them from what stays same. Program to interface not to an implementation Favor composition over inheritance The example code for strategy pattern in Swift is available at my github repo . courtesy: Head First Design Patterns