0

I'm creating a sample app which I'm following the clean architecture, my app structure now is like this :

  1. :app
  2. :firebase
  3. :library_base (which contains all the baseActivity, baseFragment, etc.. I know I could create a base_ui, base_data, module, but let's first solve this question that I'm having right now)
  4. :networking (which contains retrofit stuff)
  5. feature1
  6. feature2
  7. ....

So now, my question is, now I do not need a core module, but in case one of my featureX, needs a dependency from featureY, what should I do in this case? I'm used to have a core on my app that contains stuff like LoginSettings which contains data from the user logged and things like that, and now if I'd have to do this I could not because featureX can not depend on app, so that's why I'm thinking about adding a core module and insert all of the needs from featureX there so they can use it. (Yes, I said "all of the needs", I did not mean to create a god module, but just to start the app).

Is it necessary to create a core module? I'm not using dynamic feature tho, and also I'm seeing that on each build.gradle files I'm duplicating a lot of dependencies...

From now in the app I have everything with api should I put that in the core?

StuartDTO
  • 783
  • 7
  • 26
  • 72

1 Answers1

0

One approach would be create modules "with UI" (call them features) and "without UI" (call them libraries).

Rule is "features" can not depend on each other directly, they can only depend on "libraries". While "libraries" can depend on each other.

Now LoginSettings, SessionConfigs kind of things can be a "library" where multiple "features" (UI) can depend on. Not all features has to depend on that "library".

Jemshit
  • 9,501
  • 5
  • 69
  • 106
  • So the thing is, have like libraries "UserSettings" as a Java modules? Could you put an image or something to be more entendible? – StuartDTO Mar 20 '20 at 19:29
  • https://jeroenmols.com/blog/2019/03/18/modularizationarchitecture/ https://medium.com/google-developer-experts/using-navigation-architecture-component-in-a-large-banking-app-ac84936a42c2 – Jemshit Mar 20 '20 at 19:58
  • So, I need to create a Java library that contains a class with settings of loggin or what? And inside of that class contain attributes like username, id etc?? Can you post an example (not code) to how would be the proposal? Thank you a lot – StuartDTO Mar 29 '20 at 20:53
  • @StuartDTO you would have library module which every feature can depend on. In library module, you can have interfaces. E.g, Interface SessionData, with username and other user related stuff. Then whichever feature is responsible for login, will have class that implements this interface and override the values. That feature will also provide Dependency Injection module for this interface. Now every other features will just depend on SessionData interface and use the values – Jemshit Mar 30 '20 at 06:33