Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Is design pattern really important?

I started learning app developing about 5 months ago, and i must say I have come a long way. But I have´t paid much attention to design patterning. I just put most of my code on my viewController, not all of it, I do got some swift file models and swift files for different Views, but right now my ViewController consists of around 8000 lines of code.

The end product of this project is really good though, and i feel I have control over my code. So is design pattern really that important?

Obs: When I work on this project it is so slow, that I have to create my code in a playground and copy paste it into my project. Is that because I put almost everything on my view controller? If that´s the case, I would probably want to change my code.

1 Answer

Choosing the right design/architecture patterns will make or break your app as it grows. 8000 lines of code within your View Controller is insanity! You need to start leveraging other objects to take the work load off of the VC. It's called a "View Controller"...and by that simple definition you should aim for it to simply "control the views". Network requests...model building...and other non view control related responsibilities should be handled off of the VC. An alternative design pattern I've come to like is MVVM (https://www.objc.io/issues/13-architecture/mvvm/). It creates an extra layer between your model and controller which allows for more modular code and testable VCs.