Grabbing frogs...

Throw It Back

Are you an Exception? I'm supposed to catch Exceptions.

objectobjectobjectobjectobject

No, I'm a fish.

objectobjectobjectobjectobject

A fish? I think I'm supposed to cook those.

objectobjectobjectobjectobject

Not me. I'm an exception.

??

objectobjectobjectobjectobject
Confused? Is it an Exception or a Fish? Can it be both? Not in Java, unless it's a FishException which inherits from Exception and implements the Fish interface.

The moral of the story is that you should favor composition over inheritance. No, wait, it's that you should either handle Exceptions or Throw them - not both. No, wait, it's that you shouldn't talk to fish.

Published Friday, 10 June 2016

Vote for us on TopWebComics.com!
Our Current Rank is: 0