| Serious question about this line: "Reusing code via inheritance is fragile. Inheritance also couples interfaces to implementations, which makes reuse more difficult. This is its own topic, but even OO programmers will tell you to prefer “composition over inheritance”." Isn't the goal to have implementations of interfaces so that you can inject implementations around in order to reduce tight coupling? Implementing an interface is not the same thing as inheritance. It's adhering an implementation to a contract. Are interfaces in ObjC different than what I'm used to from Java, C#, and others? I mean this with sincerity, what am I missing? Is this a short-coming of my knowledge because I come from a strict OOP background? I've always used implementations of multiple interfaces to achieve composition. |
"protocol" seems to be the older name (per one of the guys that wrote Java):
> I'm pretty sure that Java's'interface' is a direct rip-off of Obj-C's 'protocol'
So "protocol oriented programming" is just advocating the use of swift's equivalent of java interfaces. (It'd be "interface oriented programming" in Java.)Edit: apologies if you know all this already, it just sounded like you were asking "what makes this protocol stuff better than interfaces".