oop - Does the Strategy Pattern violate the Single Responsibility Principle? -


If the single liability theory states that there should be one reason to change each object and a single strategy implemented with a strategy pattern There should be a class (by definition) there are many ways that can change for any reason, does it mean that it is impossible to implement the strategy pattern without violating the SRP?

How so? If I recall, then Strategy Pattern is basically a way to use logic / algorithm. So the client has M_Algorithm IAlgorithm's methods should be a small set if not one

So the only reason is that an Algo Implementation Class can change

  • If the algorithm If there is a change, this applies ( changes in your responsibility / behavior)
  • Or if IAlgoritm changes .. which would be rare unless you define the interface Make no mistake. (This is a change in its own public interface - it seems that this is not a violation of SRP.)

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -