Today someone asked me why you should NOT do the following:
Subclass and leave an inherited operation empty, not abstract but empty.
Now, there are very good reasons to give but my wife told me a true story that I liked so much I decided to share it:
Steve Irwin, the crocodile hunter, kept crocodiles in his zoo in cages without doors. He reasoned as follows: if the cages have doors, there will come a day that someone leaves a door open. So he made the zoo keepers jump over the fences to get into the cages.
When you subclass and leave the method empty you create a door in your code and some day, someone will open that door.
It might be completely harmless (the croc just ate) but it could also be the start of a wild chase throught the entire zoo hunting a croc that is looking for dinner.
Do not create potential hazards, Murphy lives just around the corner.
Yes, I know, there are many good reasons sending shivers down your spine that indicate there is something wrong with the code:
- why would you subclass if the inherited method does not belong in the subclass?
- what is the functional specification and justification of an empty method?
but I loved this story.