The problem is not in size, but in responsibility. Does your controller wear more than one hat? If so, paste it into multiple controllers with one job per class.
Categories help with size, but are not responsible. If you are still doing several things in one (merged) class, you still have a problem; moving them to separate files did not solve it.
The presence of several categories in one class leads to the risk of a collision of methods: the implementation of the same method in several categories, possibly by implementing it in category B, forgetting that category A already has one. This will cause a problem when the object sends itself a message, waiting for a response from one category to this message and receiving another.
Declaring all categories in the heading of the main class reduces this risk, as you can see that the other category already has a method by the name you are about to enter. However, each method you add, thereby lengthening the header file, mitigates mitigation.
If your controller has more than one hat, explode it into several classes.
I recommend Martin Fowler's book Refactoring. Refactoring your code clears it, and also explodes classes that are too large (and methods and functions) - this is a subset of such cleaning.
Of course, several classes that were once needed require a replacement for the relationship that was previously internal within the class. Cocoa provides a number of solutions:
You do not need to choose just one, and you do not need to use them all. Which solutions are suitable will depend precisely on the fact that communication requires your new classes with each other.
Peter Hosey
source share