Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Acrhitecture deisign pattern_MVC_MVP_MVVM

Look over MVC, MVP, MVVM pattern in android.
and introduce android data binding library.

You can follow this with simple project.

https://github.com/withleedh/patternChat


References
https://realm.io/kr/news/eric-maxwell-mvc-mvp-and-mvvm-on-android/

  • Be the first to comment

Acrhitecture deisign pattern_MVC_MVP_MVVM

  1. 1. Software Architectural Design Patterns (MVC, MVP, MVVM) Dongho, LEE
  2. 2. 2 2 What’ Design Pattern? A design pattern is a general reusable solution to a commonly occurring problem. Creational Structural Behavioral Meaning determines how an object is created Organize objects organize, manage, and combine the behavior of an object Range Class Factory Method Adapter(Class) Interpreter Template Method Object Abstract Factory Builder Prototype Singleton Adapter(Object) Bridge Composite Decorator Facade Flyweight Proxy Command Iterator Mediator Memento Observer State Strategy Visitor
  3. 3. 3 3 What’ Architecture Design Pattern? - Similar to design pattern, but has a broader scope View (Composit e) Controller (Strategy) Model (Observer) < Representative Architecture Pattern : MVC >
  4. 4. 4 4 Design Pattern simply explained with sample Classic MVC MVC MVP MVVM
  5. 5. 5 5 Classic MVC MODEL VIEW CONTROLLER User Event Update CheckCheck for updates Is Data update needed? Request Data update Yes Update Data UI Change No
  6. 6. 6 6 MVC in Android MODEL VIEW (XML) CONTROLLER (Activity, Fragment) User Event Update CheckCheck for updates Is Data update needed? Request Data update YesUpdate Data UI Change No Interact with Get user event Notify event Setup View
  7. 7. 7 7 MVC in android VIEW activity_main.xml ListView EditText Button CONTROLLER MainActivity findViewById() addListener (Button, EditText) childEventListener( ) getChatFromServe r() Notify Event Setup View MODEL ChatData FireBase Interact with ListAdapter.add() editText.setText()
  8. 8. 8 8 MVP Pattern in Android VIEW PRESENTER MODEL Request Data depending on event Notify event to Presenter Get Data Update Data Update UI Process business logic User Event Notify Send data View Layer doesn’t know Model anymore!! Ask view to setup itself
  9. 9. 9 9 MVP in android VIEW activity_main.xml ListView EditText Button MainActivity implements MainView findViewById(); addListener (Button, EditText) updateListView() initializeInputConsole () setListAdapter() PRESENTER MainPresenter MainView<Interface> Notify Event Ask view to setup itself MODEL ChatData FireBase Interact with updateListView() initializeInputConsole() setListAdapter() 1 : 1
  10. 10. 10 1 0 MVVM Pattern in Android View VIEWMODEL MODEL Request Data depending on event Get Data Update Data Update UI Process business logic User Event Invoke Action Update Model State change event Data Binding Update View Itself View Layer doesn’t know Model anymore!!
  11. 11. 11 1 1 MVVM in android View activity_main (xml) ListView EditText Button MainActivity ViewModel ViewModel <Interface> MainViewModel onSendButtonClicked (View view) onTextChanged() getCurrentTime() Invoke Action Bind to data Model ChatData FireBase Interact with Data Binding N : 1
  12. 12. 12 1 2 Data Binding Library Required : Android version 2.1 Android Studio 1.3 Gradle upper 1.5.0-alpha1 LAYOUT (XML) ACTIVITY Create Method and Observable
  13. 13. 13 1 3 Data Binding Library LAYOUT (XML)
  14. 14. 14 1 4 Data binding Library DataBindingUtils.setContentView() Binding Class is automatically generated based on xml, and changed base on Pascal notation standard. Activity_main.xml -> ActivityMainBinding.class
  15. 15. 15 1 5 Data binding Library Example using ButterKnife
  16. 16. 16 1 6 Data binding Library Example using DataBinding Library
  17. 17. 17 1 7 Data Binding Library LAYOUT (XML)
  18. 18. 18 1 8 Data binding Library ViewModel Just use observable to settle value. Learn more : https://developer.android.com/topic/libraries/data-binding/index.html
  19. 19. 19 1 9 Conclusion What’s COOLEST architecture in Android? There is no right answer for that. It’s depend on case by case. However, ButterKnife that we use on our app CAN BE REPLACED with Data Binding Library.

×