May I give a single class multiple responsibilities if only one will ever be reusable?
Posted
by
lnluis
on Programmers
See other posts from Programmers
or by lnluis
Published on 2011-11-02T14:07:26Z
Indexed on
2012/06/20
21:23 UTC
Read the original article
Hit count: 206
object-oriented
|srp
To the extent that I understand the Single Responsibility Principle, a SINGLE class must only have one responsibility.
We use this so that we can reuse other functionalities in other classes and not affect the whole class.
My question is: what if the entity has only one purpose that really interacts with the system, and that purpose won't change? Do you have to separate the implementations of your methods into another class and just instantiate those from your entity class?
Or to put it another way... Is it ok to break the SRP if you know those functions will not be reusable in the future? Or is it better to assume that we do not know if the functionalities of these methods will be reusable or not, and so just abstract them to other classes?
© Programmers or respective owner