KrakenDev


Here's to the crazy ones. The misfits. The troublemakers. The Swifters.

Viewing entries tagged
protocol oriented programming

Generic Protocols & Their Shortcomings

Generic Protocols, man. They. Are. Hard. Easy to create, but difficult to work with. For simple scenarios, they play well for the most part but unfortunately, the more complexity you create whilst working with them, the more you start to realize how much work needs to be done on them.

In this post, I'll walk through how to create a generic protocol, where you ***can't*** use them, and a workaround you can use to help a brotha out.

If You're Subclassing, You're Doing It Wrong.

Subclassing can suck. There are so many ways to get it wrong and it's so easy to fall into anti-patterns when you create such a tight coupling between two classes. Most of the time, the need for subclassing can actually be replaced by abstraction through protocol-oriented, value-oriented, and functional programming. In fact, I may even argue that doing it that way can far outweigh the "benefits" of subclassing the majority of the time.