This sample stands on the principles of Clean Architecture, using MVP for the presentation layer.
It's based on the MVP sample, adding a domain layer between the presentation layer and repositories, splitting the app in three layers:
- MVP: Model View Presenter pattern from the base sample.
- Domain: Holds all business logic. The domain layer starts with classes named use cases or interactors used by the application presenters. These use cases represent all the possible actions a developer can perform from the presentation layer.
- Repository: Repository pattern from the base sample.
Systems based on clean architecture have the following characteristics: separation of concerns, multilayer, independent of frameworks, independent of user interfaces, independent of databases, testable by layer, with a dependency rule that says that code dependencies can only point inwards, from lower levels like the presentation layer, to higher levels like the data layer.
The big difference with base MVP sample is the use of the Domain layer and use cases. Moving the domain layer from the presenters will help to avoid code repetition on presenters.
Use cases define the operations that the app needs. This increases readability since the names of the classes make the purpose obvious.
Use cases are good for operation reuse over our domain code.
The example application is based on the 3-tier of the clean architectural approach: the presentation layer, the domain layer, and the data layer.
The presentation layer is implemented as an MVP design pattern and it represents the application is an Android phone & table module., the domain layer contains the use cases which responsible on communicating with the data layer and applying the business logic, and the data layer is the one who responsible on getting the data from the local database and remote server.
To better understand the concept of the 3-tier of the clean architectural with the MVP design pattern, let's see another overview, but from a different perspective.
This version of the app uses some other libraries:
- Picasso: used for loading, processing, caching and displaying remote and local images.
- ButterKnife: used for perform injection on objects, views and OnClickListeners.
- CardView: used for representing the information in a card manner with a drop shadow and corner radius which looks consistent across the platform.
- RecyclerView: The RecyclerView widget is a more advanced and flexible version of ListView.
- GSON: Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to an equivalent Java object.
- Retrofit: This library used to send HTTP request to the server and retrieve response.
- ROOM Library: Room provides an abstraction layer over SQLite to allow fluent database access while harnessing the full power of SQLite.
- BlurView Library: It blurs its underlying content and draws it as a background for its children.
In order for the movieapp-mvp-clean app to function properly as of January 26th, 2018 an API key for themoviedb.org must be included with the build.
Include the unique key for the build by adding the following line to util/Constants.java or find the TODO Line.
API_KEY = "";
Copyright (C) 2018 Shehab Salah Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.