"Every family has its own Olivier", or how we came up with another multi-module architecture

Today I want to acquaint you with the option of building a multi-module architecture for Android. But first, be sure to remember the concept of Clean Architecture and why you generally need to think about the architecture of your code.





Why is architecture needed?

What is the goal of someone who has ever written or read someone else's software development reports? This is usually one of two things: 





  • either a person wants to solve some specific applied problem,





  • or he wants his product to be better. 





So what is “better”? Recently, this question has been increasingly emerging in the context of the architecture of a software product. After all, a powerful underlying architecture is an important metric for application scalability. Making any changes to the project may require you to rewrite the application almost completely. In such cases, the code is tightly coupled . Using Clean architecture helps to solve this problem. 





SOLID-. . ( ) « » 2012 .





, «». 





Source: https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html
: https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html

, MVC, MVP, MVVM, MVI lean architecture. , , .





, ?





. .  





Domain-: -. — Kotlin android-.





Data-: domain-, .





Presentation-: domain-, data-, android UI-.





, , : - , :





  1. application, : Domain Data Ui.





  2. application - feature, . 





, «feature» — , , , , . — « ». 





, , , :





, . LoginDataDependencies .





«» — API, .





  API — .  Dagger2. 





Dagger2.





, . . , . : - , - . — , , , . 





, - . Dagger 2. , .





, , , , feature : «Data Domain Presentation»





, , , 10 feature, 30 . ? - common , utils , . 





 

, . - , .





, , , .. 





:





, — , . , , . , , , UI , API/ - . — , , , , json, API? . 





: , endpoint  API, , UI ? - ? , ! ! , . , . 





, — . . , , , , . . 





.









  • / ( -, Ui) — data /sealed classes;





  • .





DI , — Data Ui — , , Dagger. 





:





  • DTO ( , );





  • API; 





  • ;





  • DTO , - , ;





  • DI 3 : 





    • Module — , ;





    • Component, Dependency;





    • Dependency ( , baseUrl API, , common — Retrofit, Json Moshi. , / providers — , ).





UI : , UI , , . . 





  • DI 4 : 





    • Module; 





    • Component; 





    • () Dependency ; 





    • UiChildComponentProvider — , DI, , « » « », . :





fun provide(module: FeatureDataModule): FeatureDataComponent







  • / DI — , -.





, / Dagger :





  , / :





  • — , . «» , . —   ,   « ».





  • — «». HostFragment: ,  / . ( , flow) — (, ).





, ?





  1. . : . 





  2. . , , .





  3. . , .





  4. . , , , , . .





, , / , , .








All Articles