Wednesday, November 20, 2013

Patterns

Android is, apparently, very bad at MVC. The setup is there: Activities act as our Controllers, the view XML files are our Views (even though you can create a view programmatically), and the models we write ourselves. But in MVC, input has to go directly into a Controller; with Android, they’re entered in the views and you’d have to retrieve input from the views. While it could work, Android is a bit more suited towards MVVM.

With this pattern, we can get out input from our View (say, an EditTextView) using our ViewModel (our Activity), which in turn would pass that information to our Model (some class we’ve written to handle the data). Our Model can update it’s information and pass that back to the ViewModel from there.

No comments:

Post a Comment