3

I have been reading about why it is more convenient to structure the packages by functionality. I understand that it has greater modularity and that it is easier to navigate in the packages.

However, what happens with projects with modules by layers?

For example:

|example-webapp     (com.company.webapp.feature1) 
  |-example-service (com.company.service.feature1)
  |-example-data    (com.company.data.feature1)

In this case, modularization with maven already separates the project by layers and internally by functionality, however the functionality is distributed in all layers, which I understand reduces the modularity. But in my opinion it is much more reusable, because if at some point you want to implement an API for example, you simply reuse the service and data modules.

So, in multi module maven project how can I strcuture by feature?

|example-webapp     (com.company.feature1) 
      |-example-service (com.company.feature1)
      |-example-data    (com.company.feature1)

It is advisable not to consider the layers?

Nicholas K
  • 15,148
  • 7
  • 31
  • 57
SerchRac
  • 171
  • 1
  • 12
  • I'm running into a similar problem. On one hand I want reusable Gradle modules, on the other hand I want package by feature inside those modules with the features own entities. They might be tied to the user object which needs to be shared across all modules and theoretically be extended with all the module-feature`s relationships. I haven't come across a real solutions, if there even is any, but this structure would really be powerful in my opinion – Marian Klühspies Oct 22 '21 at 19:33

0 Answers0