Upgrade to Pro — share decks privately, control downloads, hide ads and more …

HS Android - Clean Architecture

HS Android - Clean Architecture

Andrei Lisun, Android developer
What is good software architecture and why every Android developer should care about implementing it? I’ll answer this question by talking about golden rules of good architecture. Also, I’ll show how this rules can be applied in Android development using Clean Architecture.

GDG Cherkasy

June 03, 2017
Tweet

More Decks by GDG Cherkasy

Other Decks in Programming

Transcript

  1. Why? “My apps work without any architecture” • Architecture makes

    it easier or harder to think about problems you need to solve. • Architectural decisions stick with your app.
  2. • UI can be changed easily • DBMS can be

    changed easily • No Android framework dependencies = local unit tests Independent of UI, DB, Frameworks
  3. • More local unit tests = better • Allows to

    cover at least business logic Testable
  4. View Presenter Repository Remote data source Local data source Realm,

    SQlite Retrofit UI • Activity, Fragment • Presents data in a way decided by the Presenter • Fully passive • Has reference to Presenter
  5. View Presenter Repository Remote data source Local data source Realm,

    SQlite Retrofit UI • Makes queries to the Repository • Updates the View • All business logic here • Has reference to the View and Repository
  6. • Responsible for managing data • Manages in-memory cache •

    No business logic here View Presenter Repository Remote data source Local data source Realm, SQlite Retrofit UI
  7. Use Case Use Case View Presenter Repository Remote data source

    Local data source ... Layers Domain Data
  8. Use Case Use Case View Presenter Repository Remote data source

    Local data source ... Layers Domain Presentation Data
  9. Use Case Use Case View Presenter Repository Remote data source

    Local data source ... Clean Architecture Domain Presentation Data
  10. Use Case Use Case View Presenter Repository Remote data source

    Local data source ... Domain Presentation Independence SoC Testable DRY Data
  11. • Testing is easier • Easy to add new features

    • Code is more maintainable • Bugs are easier to isolate Pros