I just started reading about clean architecture and I'm confused on the definitions of usecase implementations.
Consider a controller class having set of functions that accepts T and returns R after executing some logic
interface IController {
fun usecase1(param:T) : R
fun usecase2(param:T) : R
}
now I can execute the use cases with the IController instance.
Another way is to define each usecases as a class and inject in other objects which requires the functionality.
class UseCase1 {
fun execute(param:T):R {}
}
class UseCase2 {
fun execute(param:T):R {}
}
what are the advantages/disadvantages between having usecases as separate units versus having it as functions of some class?
IMO, separate units add contruction and Injection overhead whereas other approach suffers 'inheritance problems over composition'. Which is the right way to go ?
Aucun commentaire:
Enregistrer un commentaire