6 ms·
POP was an exciting idea when it first came out, but in practice, it just doesn’t make sense to “orient” your codebase towards protocols. I’ve seen a project t
by 3grdlurker 5y ago
POP was an exciting idea when it first came out, but in practice, it just doesn’t make sense to “orient” your codebase towards protocols. I’ve seen a project that was faithful to this and they came up with a codebase that’s extremely difficult to maintain and read because they made more abstractions than they need, and they defined so many custom types that the requisite vocabulary became huge.
Protocols have their uses, but MVC works really well and scales really well in making apps for Apple platforms.
- iddan 5y agoRust makes a great example of POP in scale. They are called traits there but it’s the same thing
- 90minuteAPI 5y agoSwift is multi-paradigm. Improved support (over ObjC) for functional style, protocol-oriented design, and value types has led many to overuse them. Multi-paradigm isn’t a cop-out, it’s a pretty specific goal of the language. Being overly “faithful” to particular patterns will conflict with this, as you’ve likely experienced. I appreciate the ability to break out and use different styles where appropriate. That pesky “last 10%” is now far less painful. It also allows for varying styles per module based on functionality required and libraries in use.
- Someone 5y ago“because they made more abstractions than they need” If you replace protocol by trait, class, function, macro (basically anything that was invented to allow abstraction), the statement remains true, So I don’t think that’s a good argument against protocol-oriented programming.
- 3grdlurker 5y agoIf you’re not using protocols almost everywhere though, is your code really protocol-oriented? I don’t even want to bother with answering that question, though. Even Apple didn’t have a clear definition for it, so debating this point seems moot to me, I’m afraid.
- jolux 5y agoRust pretty much only has protocols, and people seem to do fine programming with it. Type classes (protocols, traits) and regular classes are both different ways of achieving polymorphism, which every abstraction needs. It’s just a question of whether you think about your application as oriented around types or oriented around objects.
- swiftaccount1 5y agoI made a new account just to ask this: 'MVC works really well and scales really well" Is this a joke? Do you have any professional iOS experience? MVC is famous for scaling terribly on iOS and resulting in view controllers with thousands of lines. MVC is great for small apps. No need to overcomplicate things. But if you're building something bigger, you should look into using the right tool for the job. Don't blindly follow a popular pattern, but choose the right pattern to make the code easy to read, easy to test, and easy to modify.
- Apocryphon 5y agoThe problem is that the Cocoa framework, even after the advent of Swift, has always been created with MVC in mind. We're now at a point in iOS where trends have rolled around and now people are saying to pick MVC because that was Apple's intention, other architectures were created because people were doing it wrong: https://medium.com/flawless-app-stories/the-only-viable-ios-architecture-c42f7b4c845d https://medium.com/flawless-app-stories/the-only-viable-ios-... Obviously most significant production apps are using variant architectures such as at the bare minimum having view models, and the introduction of SwiftUI and popular earlier frameworks such as RxSwift also complicates things. Most apps aren't using pure MVC, sure, but it doesn't mean that the architecture isn't scalable. The alternatives might also be pretty gnarly: https://developer.squareup.com/blog/ziggurat-ios-app-architecture/ https://developer.squareup.com/blog/ziggurat-ios-app-archite...
- swiftaccount1 5y agoThat's an interesting article. I find iOS architecture fascinating and spend a lot of time thinking about it. It seems like "MVC" in common usage (based on talking to other iOS devs) means spaghetti, but I guess it doesn't have to be like that. To me that article proposes a more disciplined MVC than what I've seen in real codebases. I think a lot of the architectures people come up with (like the second one you linked) try to build that discipline in. I try not to be dogmatic and instead go to core principles. Do I know what this class is supposed to be doing? Are my data and view layers reasonably separated with minimal glue code? Can a new dev easily navigate this project? It's an endless discussion with no right answer. Thanks for sharing!
- mpweiher 5y agoWell...it also wasn't really new, POP is just OOP by people who didn't understand OOP (and overcomplicated it) https://blog.metaobject.com/2015/06/protocol-oriented-programming-is-object.html https://blog.metaobject.com/2015/06/protocol-oriented-progra...
- Apocryphon 5y ago"Compiler Oriented Programming"... nice one.
- dgb23 5y agoFunny article! Yes, OO as defined by Alan Kay was about the interface, protocol or what ever we call it in a given language. It's a tool for abstraction, so you think about communicating instead of structure and state. Now, most modern (~10y/o) general purpose languages I know have moved away from ADTs or simply inheritance. Inheritance was just a means to an end and never the point.
- ribit 5y agoUnfortunately, the notion “OOP” has been taken hostage by C++ and Java and they don’t want to give it back.
- deleted 5y ago[deleted]