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.
MVP Architecture
Himanshu Dudhat | Android Developer
Why we need software design pattern
• Clear Usecases
• Easy to maintain
• Easy to test
• Very cohesive. Easy to understand...
What is role of architecture
What is a role of developer
Why we choose MVP over MVC and MVVM
• What is MVC – Model View Control
• Android provide MVC by default
• Controller is ti...
Continue...
• Why MVP
• Totally decoupled
• Each layer can easily testable separately
• Modularize code
• Usecase can be w...
What is MVP
• The Presenter
• The presenter is responsible to act as the middle man between view and model. It
retrieves d...
Clean architecture by Unkle Bobs
Source : 8thlight.com
Continue...
• Entities
• Enterprise level classes
• Usecases
• Handle the flow to and from the entities
• InterfaceAdapter...
App architecture
• Application business rules
• All use cases
• Usecases implementation
(Controllers)
• Can access Entities Classes
• Junit...
• Basic java classes or we can
say Utility classes
• That can also be functionally
tested by Junit or Mockito
• This layer...
• Logic related to UI.
• Logic related to Activity or Fragment
or View life cycle
• Fragment and Activities are only
views...
• Deliver data needed in app
• Ether from database, web api or file
storage
• For database it is recommended to
use ORM
• ...
Code Time
References
• Clean architecture by Unkle Bobs
• http://blog.8thlight.com/uncle-bob/2012/08/13/the-clean-architecture.html
...
Questions?
Thanks!
+HimanshuDudhat
@HimanshuDudhat
himanshu.dudhat@gmail.com
Himanshu Dudhat
Team Lead - Android @ Cygnet Infotech Pv...
Upcoming SlideShare
Loading in …5
×

MVP Clean Architecture

Introduction to MVP architecture and its different layer. And why it is recommended for android application over MVC and MVVM

  • Be the first to comment

MVP Clean Architecture

  1. 1. MVP Architecture Himanshu Dudhat | Android Developer
  2. 2. Why we need software design pattern • Clear Usecases • Easy to maintain • Easy to test • Very cohesive. Easy to understand • Decoupled
  3. 3. What is role of architecture
  4. 4. What is a role of developer
  5. 5. Why we choose MVP over MVC and MVVM • What is MVC – Model View Control • Android provide MVC by default • Controller is tightly coupled with view. Each action is correlated to call of Controller with view action. • What is MVVM – Model View View-Model • Model –business rules • View- layout • ViewModel- Bridge for model and view • Avoided as its newly introduced and binding is still not supported in some views
  6. 6. Continue... • Why MVP • Totally decoupled • Each layer can easily testable separately • Modularize code • Usecase can be well maintained. • Easily scalable
  7. 7. What is MVP • The Presenter • The presenter is responsible to act as the middle man between view and model. It retrieves data from the model and returns it formatted to the view. • The View • The view-interface, usually implemented by an Activity (it may be a Fragment, a View depending on how the app is structured), will contain a reference to the presenter. It will be responsible for creating the presenter object. The only thing that the view will do is calling a method from the presenter every time there is an interface action (a button click for example). • The model • Model would only be the gateway to the domain layer or business logic. The model would probably be an interactor that implements a use case.
  8. 8. Clean architecture by Unkle Bobs Source : 8thlight.com
  9. 9. Continue... • Entities • Enterprise level classes • Usecases • Handle the flow to and from the entities • InterfaceAdapter • This is a set of the adapter converts data from the format most convenient for the usecase and entities(Presenter and controllers belong here) • Framework and Drivers • Contains all the detail related to the app. UI, Framework and database etc.
  10. 10. App architecture
  11. 11. • Application business rules • All use cases • Usecases implementation (Controllers) • Can access Entities Classes • Junit or Mockito (functional testing) can be applicable here Domain Layer (Domain module)
  12. 12. • Basic java classes or we can say Utility classes • That can also be functionally tested by Junit or Mockito • This layer is not related to app business rules and it is decoupled • This layer can be used any app Entities Layer (Framework Module)
  13. 13. • Logic related to UI. • Logic related to Activity or Fragment or View life cycle • Fragment and Activities are only views in over case • Strongly connected to Android SDK • Integration testing, UI tests • Tools: Espresso, Robotium or Roboletic Presentation layer (app module)
  14. 14. • Deliver data needed in app • Ether from database, web api or file storage • For database it is recommended to use ORM • And for web api Retrofit or Volley Data Layer (Model Module)
  15. 15. Code Time
  16. 16. References • Clean architecture by Unkle Bobs • http://blog.8thlight.com/uncle-bob/2012/08/13/the-clean-architecture.html • Android arch. By Saul Molinero • http://saulmm.github.io/2015/02/02/A-useful-stack-on-android-1,-architecture/ • Other • https://github.com/antoniolg/androidmvp • http://antonioleiva.com/mvp-android
  17. 17. Questions?
  18. 18. Thanks! +HimanshuDudhat @HimanshuDudhat himanshu.dudhat@gmail.com Himanshu Dudhat Team Lead - Android @ Cygnet Infotech Pvt. Ltd. Sr. Software Engineer @ Cygnet Infotech Pvt. Ltd

×