Questions tagged [single-responsibility]
The Single Responsibility Principle states that each module in a system should be responsible for a single feature or functionality, or aggregation of cohesive functionality. Another common way to put it is to say that each module should have only one reason to change.
289 questions
1 vote
2 answers
230 views
Interface with member interface?
Let's say I am coding an C++ application which needs to drive some motors with some hardware interface (USB, Serial...). There are several kinds of motors, which expose the same services, but with ...
1 vote
1 answer
216 views
DTOs and Single-responsibility principle
I'm developing a PHP application and trying to understand DTOs in context of single-responsibility principle. Being more specific, is it a bad practice having helper methods like toArray(), getValue(),...
2 votes
5 answers
618 views
What exactly is the single responsibility principle? [duplicate]
I've generally understood the SRP to roughly mean: Each class should do one thing Exactly what "one thing" is is up for debate. However, I've recently seen claims that the entire SRP has ...
0 votes
1 answer
184 views
Validation logic dependencies and separation of concerns
I am going back and forth on an aspect of our FluentValidation and MediatR pipeline behavior implementation. We receive requests which, in a Mediator pattern, are mapped to command or query objects, ...
1 vote
4 answers
409 views
Is there any intent behind SRP other than SoC
Edit based on responses so far I am starting with an edit so as to save future contributors from going down the same path others have. I am only interested in contributions that stick to the exact ...
-2 votes
1 answer
126 views
Does my class violate the Single-Responsibility Principle? [duplicate]
Goal: I am learning about SOLID principles and trying to refactor Gilded Rose code, in order to make it fresh and clean. What I have done: I have created an AbstractItem class as follows, which "...
5 votes
4 answers
577 views
Does my outer class adhere to the Single Responsibility Principle?
I often write front end apps with a generic MVC pattern. I use javascript but this questions is language independent and relates to OOP as a whole. I struggle to understand the SRP principle and I ...
3 votes
2 answers
293 views
Under the single-responsibility principle, should caching data be a separate function from returning the data?
Suppose I have a program that returns data from an API. If its cache of the data is too old, the program downloads more data from the API, caches it, and outputs the new data. Else, the program ...