• HamsterRage@lemmy.ca
    link
    fedilink
    English
    arrow-up
    2
    ·
    11 months ago

    From a practical perspective, I think that viewing SRP as referring to “direct” responsibility is good enough for making programming decisions.

    Take the example from the Wikipedia entry. A module that compiles and prints a report. If that was split into 3 modules: one that compiles; one that prints; and one that delegates to the previous two modules to produce the output, then you would have achieved SRP. Yes, the third does two things, but it delegates them and is therefore not directly responsible for them.

    At the same time this holds with the spirit of the official definition. Each module is only responsible to one source of change.

    At a certain level of detail, your sources of change start becoming other modules and not users or Product Owners. Then it’s harder to think about SRP the “official” way. But direct responsibility is easier to make decisions on.