Posts

Showing posts from September, 2019

Decorator Design Patter Using Swift

Decorator Design Pattern It allows you to add behavior to an individual object. It helps to add such behavior changes, dynamically without affecting the behavior of the other objects from the same parent class. Decorator design pattern strong holds to Single Responsibility principle. i.e a Base concrete Object. It is somewhat similar to chain or responsibility design pattern (ex: UIViewController,UIView) where exactly one of the class handles the responsibility, ex: touch events to UITextField, the iOS infrastructure tries to find the responder who can respond to it, if you have implemented a delegate or a IBAction change event , it is directed to that root UIView -> UIViewController -> UIWindow -> UIApplication. In case of the Decorator Design pattern all classes handle the request which we will see in the example listed below. A simple example to understand with this would be creating a "Simple Coffee" object and "Coffee Latte". I will try