Skip to main content

Posts

Showing posts from May, 2005

Triple Quotes

I am sure everyone has heard of the terms single quote, and double quote, but have you heard of triple quote? Yes such a term does exist, and it means three consecutive single or double quotes. So ‘’’ is a triple quote, and so is “””.

The Samurai Principle for Exception Handling

When a method fulfills it's responsibility, it is very clear what to return. We return the desired result object. However sometimes it is a bit unclear what to do when a method does not totally fulfill its responsibility. Do we return a null, do we return a partially populated object, or do we throw an Exception. Most of these situations can be resolved by applying the Samurai Principle - Return victorious, or not at all. If a function fulfills its responsibilities, return the appropiate result object, and if it doesn't then throw an Exception. Can this principle have any exceptions? I cannot think of any at the moment. Do let me know if you come accross any.