Organizing source code as layers
There are two popular choices for organizing source code as layers. In Kotlin, the first approach is to put files into their belonging packages as layers.
In the real-life example we used, we could have the following packages in each architectural style:
- Clean Architecture:
org.example.service.negotiation.entity org.example.service.negotiation.usecase org.example.service.negotiation.interface org.example.service.negotiation.framework org.example.service.negotiation.framework.rest
- Hexagonal architecture:
org.example.service.negotiation.core org.example.service.negotiation.core.port org.example.service.negotiation.adapter org.example.service.negotiation.adapter.rest
- FCIS:
org.example.service.negotiation.core org.example.service.negotiation.shell org.example.service.negotiation.shell.rest
Enforcing the layered architecture, where only the outer layer can use the inner layer and not the other way round, can easily be done using test...