Swift Protocol Oriented Programming Tutorial

preview_player
Показать описание
#swift #ios #hhkb #coding #pop #oop
Рекомендации по теме
Комментарии
Автор

Congrats for the hands-on approach. The examples really turn POP easier and funnier to understand!

g.
Автор

I watched WWDC 2015 talk on Protocol Oriented Programming last week and was looking for a tutorial that converted an OOP approach to POP - this is the best resource I've found on it. Awesome video, thank you!

barclaysd
Автор

Taking a OOP design and converting it to POP is a great idea. Clarifies the differences very well. I’m with the guy below asking for a silent keyboard though 😊

محمدبنسراجالدين
Автор

it's a good tutorial video for showing POP from OOP. expecting more from you brother.

abymathew
Автор

For a simple situation like in the video, you could simplify your code further by replacing redundant protocols with an Enum. Here's an example:
enum RacerType {
    case gasoline(_ fuelTankSize: Int, _ fuelConsumption: Int)
    case electric(_ battery: Int, _ electricityConsumption: Int)
    case bike(_ canEnterSmallVillage: Bool)
}
protocol Racer {
    ...
    var type: RacerType { get } }

Following that, your Vehicle struct has a simpler definition: struct Vehicle: Racer, LandVehicle. Instances are then even easier to create, like so:
let honda: Vehicle = .init(name: "Honda", type: .gasoline(50, 6), numberOfWheels: 4)
let tesla: Vehicle = .init(name: "Tesla Model S", type: .electric(100, 20), numberOfWheels: 4)
let bike: Vehicle = .init(name: "Bike", type: .bike(true), numberOfWheels: 2)

Instead of extending Racer protocol individually, I extended it once and used a switch statement to get RacerType's case-specific results. I achieved a 0.99-to-1 functionality as in the video.

evergreen-
Автор

POP, TDD? - Let me explain to you with one simple example.
Smash the like button if you find it helpful, and YES! QUIETER KEYBOARD THIS TIME :)

onelineofcode
Автор

Great video, just subscribed! hope your channel grows soon, you definitely deserve more subscribers. Please continue pumping out more tutorials

anthneyjane
Автор

Hey nice video would you be able to do a video showing us how you code on the HHKB as a programmer? Ie - how you navigate the lack of arrows, selecting text, copy/paste, etc?

KENTOSI
Автор

Good job, learned a lot. Keep up please

tony
Автор

I would have given you 1000 likes if I could!

schwinny
Автор

wowww <3. Is it necessary to override info in all classes? I mean we can override info just in one extension. No?

ghulamrasoolhashmi
Автор

great content! just use a silent keyboard next time please =)

falcon