Tag Info

New answers tagged

0

Your button class does do just one thing: it manages the state of the button. The fact that the button can do multiple things or has multiple behaviors has no bearing on the single responsibility principle. Where the principle comes to bear is in the implementation -- if the button has two behaviors, each behavior should be through a different method. ...


3

I agree with Ampt's comment. In your case it would be more important to distinguish between functionality and presentation - to separate the GUI and the code that is run when clicking the button. Event handling is part of the GUI, so it can stay there, but coupling the actual functionality of the button to the GUI I would not recommend. This should be your ...


8

Most real world examples that I have found are either too simple or too complex to fully explain here. I would recommend looking at BlackWasp's articles on SRP. (Much of the content of that site can be summarized as shown below.) From the man who created the term Single Responsibility Principle: ... This principle is about people. When you write a ...



Top 50 recent answers are included