Protocol Oriented Programming has gained some traction and widely adopted ever since the WWDC talk by Dave Abrahams. Most of us already familiar with Object Oriented programming for so many years, especially with the fact that the Cocoa Touch library has been using this approach. Objective-C has used the Protocol to some degree but Swift has added more powerful features to Protocol Oriented Programming.
In this course we will look into Protocol Oriented Programming in Swift more closely and deeper to find out what it can deliver in helping us with our projects. We will start off with the understanding of Class and Struct, and how to properly initialized them based on our needs.
Class and Struct have their differences and it will impact what kind and how they can adopt to certain Protocols. Different types of Protocol property and method declarations will also affect the type of objects that can conform to its requirements.
Probably the most common use of Protocol is its role on Protocol - Delegate pattern. However we will explore many different Protocol capabilities and features, such as Protocol as type, inheritance, extension, conformance, composition, typealias to name a few.
I hope you can see the opportunity and the potential of what Protocol Oriented Programming can do in your project and am looking forward to have you joining this course.
We will do a quick review of Class in object oriented programming.
A refresher of object inheritance since we will be reviewing Protocol inheritance in the upcoming lecture.
A quick review of what Struct can and cannot do in Swift.
If you understand the following types of object initializers, you may skip this lecture:
An overview of Protocol creation and declaration.
A good understanding of property declaration in Protocol may lead to how the objects adopting the protocol initialize the instances.
The type of objects that will be adopting the Protocol could affect the method signatures of the Protocol itself.
Protocol may declare the signature of the object initializers. Find out what is the difference with a typical objects initializer.
Protocol extension can help in addressing the common implementation that can be shared among objects instances adopting the Protocol.
Learn how Protocol can inherit the properties and methods from other Protocol, also how this inheritance can help addressing Struct limitation in "object inheritance" model.
Protocol may have optional properties and functions, how do we declare them?
Learn the pitfalls of using optional properties and functions in Protocol and how to avoid them.
Find out how Protocol can be used as a type on objects' property declaration and its usage.
How to detect if an object is an instance or adopting a certain Protocol thus dictating the behavior of the object itself?
Objects can adopt to multiple Protocols, which may affect how the instances of the object being passed around as parameters to functions.
Simplify how multiple Protocols declaration is being passed around.
Protocol - Delegate pattern is one of the most common pattern used to pass data around between view controllers.
Hi! I am Andi. I have a degree in MS Information Systems and been working for a Fortune Top 25 Company for the last few years.
I am passionate about mobile development and have been using both the hybrid and native approach on my projects. I fell in love with Swift and been part of the early adopter. I truly believe Swift will become one of the development languages of the future.
I live in beautiful state of Colorado in the United States and while I am not busy coding, I enjoy biking and skiing.
My motto is never stop learning and share the knowledge. Having said that, I am ready to take you on the journey of Swift development world and hope you will be a part of it.