vendredi 26 juin 2020

Interface which just groups objects of implementations of other interfaces

I'm working on a project (a framework) and at some point I found myself surrounded by couple of interfaces which serve only one purpose: to unite several objects into a kind of group. For example:

interface-group 1 interface-group 2

Also soon I will get an important interface which represents the framework. And that interface will look like this (a kind of Locator but with explicit service-returning-methods declaration (and with grouping of these services)):

interface Framework {
    GroupOfServices1 getGroupOfServices1();

    GroupOfServices2 getGroupOfServices2();

    GroupOfServices3 getGroupOfServices3();

    ...
}

I do know that these interfaces violate ISP (but I believe it's acceptable trade-off (at least relatively to framework-class)), but I don't know whether they violate SRP or not? According to Robert Martin's "Clean Architecture" SRP is violated when several groups of people can want to change the same class. So from this viewpoint SRP isn't violated, because changes to my "group-classes" can be done only by person (or group of persons) who groups services (or something) in these classes.

And with all that I'm curious are these classes well-designed (or at least is their design worth it)?

P.S. By the way maybe there's a pattern/antipattern which I unknowingly implemented. If it is, what is it?

Aucun commentaire:

Enregistrer un commentaire