Advanced Android App Architecture Update for Android 9, Android studio 3.2 and Kotlin 1.3 - Programming Ebook

Latest

Download Programming Ebook

Thursday, December 6, 2018

Advanced Android App Architecture Update for Android 9, Android studio 3.2 and Kotlin 1.3

Advanced Android App Architecture
Advanced Android App Architecture


Book Details 
             TitleAdvanced Android App Architecture 
      ISBN-109412128347
         Author: Yun Cheng and Aldo Olivares Domínguez
     PublisherRazeware LLC
    Language: English
        Subject: Android, Kotlin
         Format: PDF, EPUB, Full Source code

Recently I bought a set of 4 books Android And Kotlin Bundle by Ray Wenderlich. As you can see in the image above, which includes Advanced Android App Architecture Update for Android 9, Android studio 3.2 and Kotlin 1.3. And now I want to transfer it to you for $ 30 (4 books), All books are the latest version and have full source code.  I will share it for you for $ 30 Includes PDF, EPUB file and full source code, you can download on Google Drive.

List books: 

1, kotlin apprentice
2, Android apprentice
3, Advanced Android App Architecture
4, Kotlin Coroutines by Tutorials

Please contact me by Email: truonghang0207@gmail.com.


Thank you.

Chapter 6: Model View

As you saw in the MVC chapter, although the MVC architecture pattern theoretically allows an app to achieve separation of concerns and unit testability, in practice, MVC didn’t quite work on Android. The problem was that the Android Activity, unfortunately, served the role of both View and Controller. Ideally, you would want to somehow move the Controller out of the Activity into its own class so that the Controller can be unit testable.

One architecture pattern that achieves this goal is MVP, which stands for Model View Presenter, and is made up of the following parts:
  • Model is the data layer, responsible for the business logic.
  • View displays the UI and listens to user actions. This is typically an Activity (or
    Fragment).
  • Presenter talks to both Model and View and handles presentation logic.
The Model-View-Presenter pattern

With MVP, the Model remains the same as with the MVC architecture. The Model is the data layer, and is responsible for the business logic: retrieving the data, storing the data and changing the data. In your sample project, your business logic revolves around movies, so the Model is composed of the Movie data object, the LocalDataSource, which interacts with the local database. It is also composed of the RemoteDataSource, which interacts with the Movie Database API over the network.

The View is also the same as with the MVC architecture, responsible for displaying the UI, except that, with MVP, this role is specifically designated to an Activity or Fragment. The View will hide and display views, handle navigating to other Activities through intents, and listen for operating system interactions and user input.

The Presenter is the glue class that talks to both the Model and View. Any code that does not directly handle UI or other Android framework-specific logic should be moved out of the View and into the Presenter class. For example, while the View will listen for button clicks, the presentation logic of what happens after a user clicks a button should go into the Presenter class. Similarly, when the Model has updated, it is not the responsibility of the Model to know how the View ultimately wants to display the data.

It is the Presenter’s job to do any additional mapping or formatting of the data before handing it to the View to display it. This kind of logic is known as presentation logic, and it is handled by the aptly named Presenter.

While the View extends from san Activity or Fragment, the Model and Presenter do not extend Android framework-specific classes, and, for the most part, they should not contain Android framework-specific classes. In other words, there should be no references to the com.android.* package in the Model or Presenter. As you will read later, this rule allows for both the Model and the Presenter to be unit tested with this pattern. 

No comments:

Post a Comment