Sunday, November 8, 2015

Why should I care about the sealed keyword in C#?

Let's say I own a pair of scissors and I only ever use the scissors when they are closed as either a letter opener or an icepick. Then one day it occurs to me that I could just put a padlock on the scissors so that anyone else who stumbles upon them cannot accidental cut themselves with them when they really never need to be opened. Why would I be so paranoid and take the time to do this when I have to do so explicitly? (I didn't buy the scissors with a padlock on them to begin with after all.) Why wouldn't I leave open the potential for another function? Similarly, I don't see why I should live in fear of someone extending something I've made and creating a Liskov violation.

Shouldn't I just assume my teammates aren't going to do something stupid?

No comments:

Post a Comment