The single-responsibility tag has no wiki summary.
2
votes
3answers
292 views
Do setters and getters always break the Single-Responsibility Principle?
As we know, The SRP states that every class should have single responsibility and that responsibility must be entirely encapsulated by the class.
But setters and getters do serve another ...
2
votes
2answers
196 views
Architecture Best Practice (MVC): Repository Returns Object & Object Member Accessed Directly or Repository Returns Object Member
Architecturally speaking, which is the preferable approach (and why)?
$validation_date = $users_repository->getUser($user_id)->validation_date;
Seems to violate Law of Demeter by accessing ...
3
votes
2answers
276 views
Questions about identifying the components in MVC
I'm currently developing an client-server application in node.js, Express, mustache and MySQL. However, I believe this question should be mostly language and framework agnostic.
This is the first ...
-1
votes
1answer
450 views
Low Coupling: Single Responsibility Principle vs Cohesion
I've read several articles on SRP and cohesion, and they seem to contradict each other as far as low coupling is concerned.
Articles on cohesion argue that putting closely related responsibilities ...
9
votes
2answers
360 views
Is there an “ask for only what you need” interface principle?
I have grown into using a principle for designing and consuming interfaces that says basically, "ask for only what you need."
For instance, if I have a bunch of types that can be deleted, I'll make ...
11
votes
6answers
637 views
Does multiple inheritance violate Single Responsibility Principle?
If you have a class which inherits from two distinct classes, does not this mean that your subclass automatically does (at least) 2 things, one from each superclass?
I believe there is no difference ...
5
votes
3answers
584 views
What is the difference between Single Responsibility Principle and Separation of Concerns
a)What is the difference between SRP and SoC? Perhaps that SRP is applied at class level, while SoC can be applied at system, subsystem, module, class or function levels.
b) If answer to a) is yes, ...
1
vote
1answer
133 views
Something confusing about Single Responsibility Principle
1)
In fact if two responsibilities are always expected to change at the
same time you arguably should not separate them into different classes
as this would lead, to quote Martin, to a "smell ...
5
votes
4answers
443 views
How to determine if class meets single responsibility principle ?
Single Responsibility Principle is based on high cohesion principle. The difference between the two is that highly cohesive classes feature a set of responsibilities that are strongly related, while ...
3
votes
2answers
181 views
Should these concerns be separated into separate objects?
I have objects which implement the interface BroadcastInterface, which represents a message that is to be broadcast to all users of a particular group. It has a setter and getter method for the ...
9
votes
6answers
595 views
Struggling with the Single Responsibility Principle
Consider this example:
I have a website. It allows users to make posts (can be anything) and add tags that describe the post. In the code, I have two classes that represent the post and tags. Lets ...
21
votes
12answers
1k views
When does the “Do One Thing” paradigm become harmful?
For the sake of argument here's a sample function that prints contents of a given file line-by-line.
Version 1:
void printFile(const string & filePath) {
fstream file(filePath, ios::in);
...