Linked Questions

2 votes
5 answers

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 ...
ScottishTapWater's user avatar
0 votes
1 answer

Granularity of the Single Responsibility Principle [duplicate]

This is a related question and the OP appeared to go with extreme levels of granularity. The answers gave a good overview but I gather it's still somewhat down to personal interpretations/situations ...
IMB's user avatar
  • 343
0 votes
0 answers

Understanding Single Responsibility Pattern (SRP) [duplicate]

According to the Single Responsibility Pattern (SRP) a method or class should have one responsibility. I have read a couple of sources and viewed some videos and I would like to understand it by ...
030's user avatar
  • 548
83 votes
8 answers

How can a class have multiple methods without breaking the single responsibility principle

The Single responsibility principle is defined on wikipedia as The single responsibility principle is a computer programming principle that states that every module, class, or function should have ...
Goose's user avatar
  • 1,898
50 votes
7 answers

Managing and organizing the massively increased number of classes after switching to SOLID?

Over the last few years, we have been slowly making the switch over to progressively better written code, a few baby steps at a time. We are finally starting to make the switch over to something that ...
JD Davis's user avatar
  • 1,377
12 votes
6 answers

What are the practical ways to implement the SRP?

Simply what are the practical techniques people use to check if a class violates the single responsibility principle? I know that a class should have only one reason to change, but that sentence is ...
Songo's user avatar
  • 6,598
9 votes
8 answers

Single Responsibility Principle Violation?

I recently got into a debate with another developer regarding the below class: public class GroupBillingPayment { public void Save(IGroupBillingPayment model) { if (model == null || ...
gvk's user avatar
  • 335
1 vote
4 answers

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 ...
Ash's user avatar
  • 219
4 votes
3 answers

How to apply the single responsibility principle if the program should do a lot of things?

If I need to write a program that Reads a json file Converts its data to yaml Writes it to yaml file and adhering to the single responsibility principle I create classes like FileReader ...
Bob's user avatar
  • 151
4 votes
4 answers

How to do "Separation of concerns"

I understood(edit: I assume) the importance of seperation of concerns and benifits in an application, But struggling to identify what are considered to be a concern (developer, feature, consumer or ...
Karthi Fair Hawn's user avatar
6 votes
1 answer

Which design is better for this problem?

I have a problem and I want to know what is the best way to solve it. Problem: I have a Binary Decision Tree. Each leaf node has an object (called Matrix) that stores some information and performs ...
Mehran Mirkhan's user avatar
5 votes
4 answers

Should data sanity checks be separated from methods that insert the data?

I have a simple example of two setups of the same block of code, but i am not sure what would be considered the "better" option, although subjective, i read about methods often doing too much than ...
Dave's user avatar
  • 169
2 votes
3 answers

Finding object responsibilities while designing a book reader

The biggest difficulty I am having is finding responsibilities of each object identified by me in the system or so called problem space. I am positing a very simplified description of a book reader. ...
CodeYogi's user avatar
  • 2,176
0 votes
2 answers

Why doing more than one thing in a class is sometimes valid? [duplicate]

classes and method should do one thing like the code below: class A { public int a() { b(); } private int b() { c(); } private int c() { } } The code mentioned below I found it ...
Sajied Shah Yousuf's user avatar