Hacker News new | ask | show | jobs
by bennyg 4619 days ago
I absolutely think about clean and quality code. The easiest way to do it, in my opinion, is to write the most customizable and modular code from the beginning. Because, inevitably, mid-project you'll want to use something you've already written with a slight twist or use a class somewhere else where you didn't know you'd need it - but now you can just drop that sucker in and spend no time making a totally new class for something so it doesn't break something you've made earlier. It really doesn't take too much extra time to do this either, especially if you're constantly thinking like that - future proofing your code for the unknowable and very changeable design requirements. Loosely sticking to MVC has greatly improved my app coding. Here's how I set it up:

* Controllers

* Data Objects

* Utility UI functions (making shadows, or anything that can happen anywhere)

* Data Managers (sometimes Singletons)

* Web Services

If I start with this model in my head, the code is self organizing because I'm not writing data parsing in a controller because I KNOW with 99% certainty that I'm going to parse something later in another controller or something even higher is going to handle that data at some point in the future.

This kind of abstraction is how I do it currently, and I've only gotten here through experience, and I'm sure that I'll find even better ways as I continue to code into the future (I'm already thinking of base iOS project templates that contain that structure already).

1 comments

Awesome. This is something I try to follow. I use the same concepts that you have listed here. Conforming to the MVC pattern makes it easier to develop. Since my team is using Parse, we don't have to worry about Data Objects and Web Services, but we do have Controllers, Data Managers and Utility functions in our app.

I checked out your github account for the HN app and it is a beautifully written one. Great work.

Thanks man, I've been refactoring and learning as I go on that one as well. It used to be not-so-nice not too long ago haha.