jeudi 4 novembre 2021

Spring - Package structure - [.../compontent/layer] vs [.../layer/component]

We currently have a larger Spring project, which consists of different project components. Unfortunately, the packaging is currently relatively unfavorable, which is why I want to refactor the whole thing.

Our basic framework uses package by layer, which is why I - at least for the time being - would like to stick with it in our project. I would like to ask you which kind you consider more useful:

variant 1:

- src/main/java
     - com/company/core
       - dao
       - domain
       - dto
       - service
     - com/company/component1
       - dao
       - domain
       - dto
       - service
     - com/company/component2
       - dao
       - domain
       - dto
       - service
     - com/company/component3
       - dao
       - domain
       - dto
       - service

variant 2:

- src/main/java
     - com/company/dao
       - core
       - component1
       - component2
       - service
     - com/company/domain
       - core
       - component1
       - component2
       - component3
     - com/company/dto
       - core
       - component1
       - component2
       - component3
     - com/company/service
       - core
       - component1
       - component2
       - component3

In terms of content, I like variant 1 very much, because the components come out better - but the whole thing is neither package by feature nor package by layer? Should you even do such a mix?

Which variant would you choose or which varainte do you use in your environment?

Aucun commentaire:

Enregistrer un commentaire