DEV Community

Davmi Jose Valdez Ogando
Davmi Jose Valdez Ogando

Posted on

100 Days of Swift - Day 11

Continuation of Hacking With Swift 100 Days of Swift

Day 11 - Protocols
(Maybe just call them interfaces?)

So protocols are in swift what interfaces are in any other language, but here protocols are a bit on steroids, and here is why. You have your usual stuff around them, access modifier, define the behavior of whoever implements them, you can abstract the concrete class by using the protocol in a parameter, etc.

What makes them powerful is the fact that they serve sort of an abstract interface when matched with Extensions, these allow you to modify data types (structs and protocols) to add a desire behavior and at the same time when paired with protocols it helps them have a default functionality, so whenever a class implements the protocol it doesn't have to build the body of all the protocol member's (so an abstract class).

Man this journey makes my brain hurts a bit.

Top comments (0)