3 ms·
Doubling Down on Protocol-Oriented Programming
- sidraval 10y agoWe've been working on something similar at thoughtbot - https://github.com/thoughtbot/Swish https://github.com/thoughtbot/Swish
- partycoder 10y agohttps://github.com/facebook/swift https://github.com/facebook/swift
- gue5t 10y agoThis is about Swift "protocols" which are more like "interfaces". It isn't about network protocols or process calculi.
- delinka 10y agoThe term "protocol" is held over from Obj-C. I guess because in Obj-C, the declaration of a class is wrapped in @interface...@end (the implementation is inside @implementation...@end) And it's annoying to have to explain this to all the other devs on the team who don't use Obj-C. Here's hoping Swift fixes the vocabulary. EDIT: I suppose the main difference between Swift's "protocol" and Java's "interface" is that Swift lets the dev provide actual implementations for some declared functions. "Protocol" is still not an idea word in my opinion.
- BrandonM 10y agoJava 8 added default and static methods to interfaces.
- delinka 10y agoI'm not experienced with Java since ... long ago. Thanks for the information.
- Someone 10y agoA major difference is that, in Java, the only way to make a class implement another interface is by changing its source. In Swift, on the other hand, one can make a class conform to a protocol, even if one does not have access to its source code (https://www.andrewcbancroft.com/2014/12/02/send-a-type-to-obedience-school-using-swift-extensions-for-additional-protocol-conformance https://www.andrewcbancroft.com/2014/12/02/send-a-type-to-ob...)
- jernfrost 10y agoIt is interesting to see the development of new patterns of working caused by the features introduced in Swift. There is so much here I wish I had when I struggled with many software design issues in C++.