Connect with us


How useful is the coordinator pattern in an iOS application?

I think what’s happening these days is everyone is trying to implement patterns to make their code more robust and testable which I agree and support, but using a sword in the place of a needle is a bad approach.

Coordinator pattern is the latest “buzz word” that’s been going around in the iOS world although this pattern was already there from 2015 but recently it has caught the attention of many iOS devs and today we will try to find out how much value does this pattern provides in our application.

The scope of this article is not to explain what the coordinator pattern is and how we can implement it, but it is to determine the worth of adding this pattern in our projects.

If you know the Hindi language then do check out my YouTube channel where I have explained what this pattern is along with how we can implement clean coordinators in a 3 part video. The 3rd part is where I present how we can implement clean coordinators with protocol-driven programming.

Coordinator pattern is a fancy term for the delegate protocol pattern.

This delegate pattern isolates the navigation controller from the view controller and takes over the navigation responsibility.

Using the coordinator pattern we don’t have to use the segues for navigation, also we don’t need to write all that navigation code inside the view controller.

So this means using this pattern we decouple the navigation related task from the view controller and delegate the navigation responsibilities to the coordinator class.

Mission accomplished, no more coupling between the view controller and navigation. Plus now a single class is managing the navigation so SRP (Single responsibility principle)

But wait, every pattern has a trade-off and we must understand what those trade-offs are before we start celebrating and implementing this pattern in our client projects.

The very first thing is the need for the pattern, if one simply implements a pattern for no reason then it’s an abuse of the pattern.

Full Article: Codecat15 @ Medium