Introducing the model-view-controller pattern
The model-view-controller pattern involves the separation of different aspects of our app into distinct parts called layers. Android apps commonly use the model-view-controller pattern. A pattern is simply a recognized way to structure our code and other application resources such as layout files, images, databases, and so on.
Patterns are useful to us because by conforming to a pattern, we can be more confident we are doing things right and are less likely to have to undo lots of hard work because we have coded ourselves into an awkward situation.
There are many patterns in computer science but an understanding of model-view-controller (MVC) will be enough to create some professionally built Android apps.
We have been partly using MVC already, so let's look at each of the three layers in turn:
- Model: Model refers to the data that drives our app and any logic/code that specifically manages it and makes it available...