hyperoslo / iOS-playbook

Hyper's iOS playbook
Other
227 stars 28 forks source link

View-models #119

Open attila-at-hyper opened 9 years ago

attila-at-hyper commented 9 years ago

Recently we had some discussions on pros and cons of introducing view-models. I still have some concerns and I'd love to have your feedback.

I do see the benefit of moving code out of the view controllers (a.k.a. "dumb view controllers"): unit/automated testing. I just don’t see why it should go to an extra layer (view-model) instead of going to an existing layer (model). To me “model” is more than just a “dumb” data storage: there is code (“business logic”?) which links the data we store to the UI where we show/the user manipulates it. This code should go somewhere. So far it was mostly the view controller which makes unit testing difficult (but not automated testing - that’s another story). Too bad. I just don’t see why it’d be better to add one more layer (more classes, more files). Simple is beautiful.

3lvis commented 9 years ago

I think the main concern is sending UI code to the model, which misses the point of using the model for model related operations and business logic.

So the idea of a ViewModel is to have a clear separation over UI specific helpers and application (business) specific helpers.

I do agree with your point on that adding a new layer and a new dogma (MVVM) could make this less simple.

Make sure to read this issue to understand other points.

https://github.com/hyperoslo/iOS-playbook/issues/112