Question

SRP(PDF version; HTML version) states that

There should never be more than one reason for a class to change

When you take a look at Outlook, Calendar Event window, it has "Save and Close" button.

alt text

So when the functionalities of either or both Save or Close changes, that button should change. It obviously violates SRP.

This functionality both saves time and convinient since that is what most of users expect to do when they save an appoint on a calendar.

But now, my question is, when else do you violate SRP other than when the feature need to be usuable in Outlook?

Was it helpful?

Solution

SRP does not apply to UIs. Keep in mind that even though the button is called "Save and Close" there can undoubtedly be two separate methods or types to handle the saving and closing functionality. The button simply ties those two separate pieces of functionality together.

If you feel the need to violate SRP then you need to re-evaluate your approach. Any SRP violation can be refactored into a new method or type that exposes the composite functionality by means of composition of the two pieces.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top