Polymorphism is a fundamental object-oriented programming concept; however, it's also very important in POP. It is imperative to understand it and apply it correctly. In this video,watch how to build a demo that relies on protocols and polymorphism.
- [Instructor] Polymorphism is a fundamental…object oriented programming concept,…yet it's also essential to POP.…Polymorphism comes from Greek,…and means many forms.…In programming, it denotes the ability…to provide a single interface to different types.…To illustrate the concept, I went ahead…and created a playground project.…Let's open it by going to the Desktop,…Exercise Files, chapter two, 0204, and Start.…
I'm going to open the Polymorphism playground.…The Shape protocol defines the read only…getable area property.…This is the only property requirement…that conforming types must implement.…We've created several concrete shapes…that conform to the shape protocol,…square, rectangle, rhombus, and circle.…Now let's define a variable of type shape.…We can't instantiate the shape protocol directly,…yet we can take advantage of the polymorphic behavior…and assign any of the concrete types to the shape variable.…
For example, I'm going to assign a rectangle instance first.…Let's say 10 by 20.…I'm going to print out the shape's area.…
- Comparing object-oriented programming with protocol-oriented programming
- Methods and class-bound protocols
- Adopting a protocol
- Declaring asynchronous behavior
- Preparing and implementing fallback logic
- Implementing an app using protocol-oriented programming
Skill Level Intermediate
1. Protocol-Oriented Programming
4. Implement the Weather App Using POP
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.