I recently watched the 'Network Apps for the iPhone OS' videos for WWDC 2010 in iTunes U and the speaker said that the best place to write your networking code is in the model. This kind of confused me because I have always placed this code in the controller classes. Can someone please explain why this is the best place for the networking code? Also if possible please provide an example, code or pseudocode, either works.
I wonder if we're all using the same terminology? Here's what I would use and I think (though I'm saying this without much context) what the WWDC presenter meant:
Using these definitions, the controller is a terrible place to keep any networking code. It has nothing to do with the interaction between the UI and the data.
Of course there's no reason why you couldn't have multiple classes for your model: one for the data representation and another to mediate between your web service and your data model. In this sense it would be a controller but would, nevertheless, be in the model layer of the application.
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