How can I structure my project if I have a facade?
The controller will call the facade to call the class in another package and the self package?
Like:
feature/
├── order/
│ ├── OrderController <== here calls Facade
│ ├── OrderService
└── facade/
│ ├── CheckoutFacade <== here calls orderService(go to facade and back to self package) and personService
└── person/
└── PersonService
Should I create a controller package separately of feature?
You could organise package as: [now I think it's totally wrong]
[EDIT] this below is a bit missleading
orderfeature/
├── OrderController <== here calls Facade public
└── service/
├── CheckoutFacade <== here calls orderService(go to facade and back to self package) and personService - public for test purpouse
├── OrderService (might be package scope)
└── PersonService (might be package scope)
[EDIT] this one is acceptable!
orderfeature/
├── OrderController <== here calls Facade public
├── CheckoutFacade <== here calls orderService(go to facade and back to self package) and personService - (might be package scope)
├── OrderService (might be package scope)
└── PersonService (might be package scope)
with experience comes also some conclusions for now in my projects I have this kind of structure
the way I do it for now is:
orderfeature/
└── api/
├── OrderController <== PACKAGE SCOPE [autowiring CheckoutFacade and so on.., and there is no need to make it public]
└── exceptions/
├── ExampleException <== PUBLIC SCOPE
└── dto/
├── ExampleDTO <== PUBLIC SCOPE [to communicate with facade]
├── CheckoutFacade <== PUBLIC SCOPE
├── OrderService <== PACKAGE SCOPE [service is hidden]
├── PersonService <== PACKAGE SCOPE [service is hidden]
├── ExampleRepository <== PUBLIC SCOPE [repository interface is public]
├── ExampleRepositoryInMemory <== PACKAGE SCOPE [repository interface
└── FeatureConfiguration <== PACKAGE SCOPE [ex spring bean config]
And i'am really happy