Upload
uptech
View
52
Download
1
Embed Size (px)
Citation preview
Clean Architecture in Androidwell not only in Android, but we did it here
prepared by Halyna Halkina
The simplest way
Activities and Fragments (and sometimes even Adapters, brr)
contain everything. All the API calls, saving to DB, logic
manipulations are in them
Let’s move logic somewhere!
Logic doesn’t belong in the UI. We would like to have some
place where we’ll keep it separately from Views, Activities and
Fragments
That’s exactly how we got Managers
Logic classes: Pros
● UI separation from other application stuff
● Ability to split functionality into several Logic Classes
● A bit cleaner code :)
Why bad?Managers (or just collections of random somehow connected logic) tend to grow and
grow as you get more use cases
Clean Architecture: Pros and characteristics
● Independent of Frameworks
● Independent of UI
● Independent of Database
● Independent of any external agency
So what does it all add up to?We ended up with given scheme:
● Presentation layer - Model-View-Presenter
● Domain layer - Use Cases (using both data layer’s Data
Stores and network API)
● Data layer - Data Stores (storing data in the DB and in
memory cache, using API to get/update information)
ReferencesUncle Bob’s article about Clean Architecture
Fernando Cejas Clean Architecture in Android articles part 1 and part 2
Guide on implementing Clean Architecture in Android by Dario Miličić
An article about MVP
Advocating Against Android Fragments
Series of 3 articles about MVP (with examples)