I have some experience in iOS development (more Java background) and recently I've started to read "Clean Code".
I've noticed that in my iOS projects I have a lot of anti-patterns.
2 most popular recommendations I don't follow properly: Small methods and Small Classes. Then I made small research on GitHub and I din't find project that I can use as example/reference for "Clean Code".
In most of the cases ViewControllers has tens of methods AND they have HUGE methods, like loadView
where we programmatically build hierarchy of views.
For instance example app from Facebook wishlist-mobile-sample has 1431 lines of code in HomeViewController
class, and its loadView
has 170+ lines of code.
Do you have links to the projects you would recommend as a really good coding example?
I dare to dispute that having all classes < 100 lines of code is really a best coding practice ... It all depends on what you use it for, and how important it is to have a class really clean and general. I know quite some pieces of code that are easier to read with hundreds of lines in a class than class-cluttered code with super-mini classes, but hundreds of classes instead ... There is probably a reason lots of projects have bigger classes.
And do you really think that if the statement is "a function should have max. 100 lines of code" that having a function with 130 lines already qualifies for bad coding?!?
BTW: The viewDidLoad
function in the UICatalog
class from Apple has 42 lines of code - the rest is whitespace and comments - I'd rather not leave those out of your code in order to stay under 100 lines :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With