4 ms·
Holy fat controller! This whole source code is mostly in just a single file. https://github.com/sveinbjornt/Sloth/blob/master/source/SlothController.m https://
by gregkerzhner 8y ago
Holy fat controller! This whole source code is mostly in just a single file. https://github.com/sveinbjornt/Sloth/blob/master/source/SlothController.m https://github.com/sveinbjornt/Sloth/blob/master/source/Slot...
Curious what patterns you iOS developers out there do to avoid code like this? Personally I am a big fan of ReSwift.
- Pulcinella 8y agoThis[1] video with Andy Matuschak helps with refactoring these “Mega” controllers. This[2] article also is good when it comes to breaking down controllers into smaller pieces. I will admit it’s a hard problem for me. Putting everything into one view controller is so easy and makes certain problems go away. e.g. Storyboards are a lot easier to deal with when their outlets are in the massive view controller. Custom UIviews with storyboards are a huge pain to get working with interface builder. [1] https://academy.realm.io/posts/andy-matuschak-refactor-mega-controller/ https://academy.realm.io/posts/andy-matuschak-refactor-mega-... [2] https://www.smashingmagazine.com/2016/05/better-architecture-for-ios-apps-model-view-controller-pattern/ https://www.smashingmagazine.com/2016/05/better-architecture...
- fouc 8y agoThe code is pretty clear though. It is well laid out and doesn't feel cluttered.
- svth 8y agoAuthor of Sloth here. The controller didn't start out quite so fat, the whole thing was quite slim, 400-500 lines, when I first put Sloth together some 15 years ago. It grew as various additional features piled on over the years. However, your point is well taken. I should refactor things at some point.