I have a service classes which depends on multiple other service classes.
class Service1 {
}
class Service2 {
}
class Service3 {
}
class Service4 {
}
class Service5 {
public Service5(Service1 s1, Service2 s2, Service3 s3, Service4 s4);
}
Is there a design pattern/best practices where I can avoid passing multiple services to Service5 constructor. It gets complicated when other service (service1, service2 etc), needs to invoke service5 for some execution as it can cause circular dependency.
One solution I can think of is having a ServiceCollection static class on which have getters for all services.
Aucun commentaire:
Enregistrer un commentaire