Posts

Showing posts with the label protocol

Protocol oriented programming PoP

This post is a part of my blogpost series while learning Swift and Programming paradigms. First part on Functional Programming can be found here . Protocol oriented programming (POP)  can be said as as - a way to adhere the " Program to interface not to implement " principle  - which is one of the basic design principles of software development. Structure your code such that you define interfaces first then make the classes implement it. Define interfaces using protocols and then make classes implement them. POP is just another technical term for the interface programming in Swift programming language. Yes! There are additional advantages of POP in swift using "Extensions" along with protocols in Swift. Let us discuss this with a classic example - Shapes and its classes . Any shape has area. Every shape needs to be drawn on some canvas. Typically an average programmer thinks: Let's have a base class named Shape. Let's derive all other concrete cl