DEV Community

Discussion on: Understanding SOLID: Single Responsibility Principle

Collapse
 
themelis profile image
Themelis

First of all I really liked your post and the example that you've provided.
Secondly I would like to comment on the "WHY WOULD I WANT TO DO THIS?" section. I get the feeling as I read it that whenever I implement SOLID or SRP I will always have an improvement on the code, which I don't believe is true since it get's more complicated.

As Matthieu said for example, can you imagine creating all classes with only one method? That's practically insane isn't it?

I would like to think about it like this: we don't go looking for cases to implement SOLID or SRP or any other pattern until we come to the case that we need it.

Collapse
 
nomikz profile image
nomikz • Edited

Oh deer.. Probably, you have never had to deal with maintaining huge legacy monoliths.
It is generally a good idea to follow best practices from the start. As the project grows, technical debt will start getting accumulated really fast.

Collapse
 
themelis profile image
Themelis

It's true I've never delt with huge legacy monoliths mainenance and following best practises from the start (and along the way) sounds logical to me. All I am asking: is implementing SOLID or SRP always a best practise? Aren't there cases that introduces needless complexity and overdesign (as Robert Martin states)?

Thread Thread
 
nomikz profile image
nomikz • Edited

It is good to learn good practices early on.
What is really bad is premature optimization :D