As a consultant working for multiple companies that are using maven multi modules I have made the same discovery with all of them that I find strange. Lets say they want to build a webapp for a hospital that manages staff and patients. Assume that they are separate domains. The project would look like this:

----PatientsService.java (public to be accessed by PatientsController)  
----StaffService.java (public to be accessed by StaffController)  
----Patient.java (public to be accessed by PatientsService)  
----Staff.java (public to be accessed by StaffService)  

Because of the module name in each package a class that is used in the module above has to be public. Which leads to the fact that for example the PatientsController can access PatientsService but also StaffService. If we omit that module name in the packages we could make them package-private. So we gain a package-by-feature structure and PatientsController can only access PatientsService.

In conclusion we have a top level package-by-layer multi module structure that helps us technically for building each module separate but also we have a package-by-feature structure over all modules.

Why would one not want to do that?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.