Model-View-Presenter architecture

As mentioned earlier, the software needs to be testable. Only then can we write efficient tests for them. For this reason, you will architect your app using the Model-View-Presenter (MVP) architecture. This architecture employs some design best practices such as inversion of control and dependency injection, thus making it suitable for testing. For an app to be testable, it has to have its parts decoupled as much as possible.

Check out the high-level diagrammatic view of an MVP architecture in the following diagram:

Very briefly, this is what the various parts mean:

  • Model: It provides and stores the app's data
  • View: It handles the display of the model's data
  • Presenter: It coordinates the UI with the data

You could also easily swap out other parts and mock them during testing. In software testing, mocks are objects which mimic real objects. You will provide its behavior instead of relying on the actual implementation of the code. This way, you get to focus on the class under test, which is doing exactly as expected. You will see them in action in the following sections.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset