-
Notifications
You must be signed in to change notification settings - Fork 6
1. Architecture
Starting the development of software without a clear architecture will cause a disaster. The same way that starting construction of a building without a clear architecture will cause a disaster. It is true that without an architecture you can go really fast for the first few features in the app but does that really matter! If you are not able to do any major changes in the software after a year. Logging with google took one week to implement but after one year of development logging in with Facebook took a month or two and even then it was really buggy. If you are too scared to do anything in the software after a few years. Does building the first few features fast really matter?
“The only way to go fast, is to go well.” ― Robert C. Martin, Clean Architecture
There are multiple common architectures that you can use for your software. But I think clean architecture is the most commonly used architecture in the android development community. So I choose to use clean architecture for this template. While studying Clean architecture I read multiple articles about implementing clean architecture in android. I also checked a few GitHub repositories but most of them didn't have what I wanted. I believe most of them are the wrong implementation of clean architecture and the implementation violated the architecture principles. So for this template, I will depend on this article by Robert C. Martin
As shown in the above diagram the template consists of 4 architecture layers. Be careful that those layers are architecture layers AND YOU DON’T HAVE TO CREATE A MODULE FOR EACH LAYER. Software components (modules) are different from architecture layers. You can have as many software components as you need in each architecture layer. In android, we create software components by modules. So for example we can separate our entities into two different modules or even more. The same thing applies to use cases and other layers.
For this template, eight different software components have been used as shown in the diagram.
- In the innermost layer, we have an entity which is a java module.
- Then In the second layer, we have useCase another java module.
- For the third layer, we have two modules: repository and ViewModel both of them are android module with as minimum dependency as possible on the android platform.
- And in the outermost layer, We have 4 heavily dependent on the android framework modules. The application is our actual application module. UI, Remote and DB are also android modules.
Of Course, you can have more layers but I don’t think having fewer layers will be a good idea. For this template, we are trying to have the most basic implementation possible so we go with 4 layers.
Copyright (c) <2021> <Muhammad Khoshnaw>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.