zwa
3f4d5bb4d6
Co-authored-by: Michael Jerger <michael.jerger@meissa-gmbh.de> Co-authored-by: ansgarz <ansgar.zwick@meissa.de> Reviewed-on: #4
1 KiB
1 KiB
ADR: We implement domain services static
Domain services can be implemented either as object (and composed like done in spring / example1 ) or with extension function and composed static (see example2).
example1
class DesktopServie(val aptApi: AptApi, val prov: Prov) {
fun provisionIdeDesktop(onlyModules: List<String>? = null) {
prov.task {
if (onlyModules == null) {
aptApi.aptInstall(OPEN_VPM)
}
}
}
}
example2
fun Prov.provisionIdeDesktop(onlyModules: List<String>? = null) {
if (onlyModules == null) {
aptInstall(OPEN_VPM)
}
}
Decission
We use extension function and composed static.
Reason
- Similar to composed objects we can easily mock
aptInstall
in tests. Both solutions are equivalent. - Inheritance in case of composed objects we can solve by static composition.
- Object composition we can solve by static composition.
There is no reason left to change the current implementd pattern.