By December 1, 2011 1 Comments Read More →

A New Kind of Exception

This post has 245 words. Reading it will take approximately 1 minute.

GD Star Rating
loading...

This is my go to considered harmful1), my object orientation2), my data encapsulation3).

I give you the ImTiredOfThinkingException. Whenever you are too lazy to think things thru, simply throw an exception and move on to shinier things. I’ve even made it an unchecked exception, so I won’t have to worry about catching and handling it.

Here’s an example of its use:

List<Pair<Pair<Set<AP>, Set<AP>>, Node<AP>>> cloneList = transitions.get(clone);
if (cloneList == null) {
	cloneList = new ArrayList<Pair<Pair<Set<AP>, Set<AP>>, Node<AP>>>();
	transitions.put(clone, cloneList);
} else {
	throw new ImTiredOfThinkingException(
		"This most likely shouldn't happen, but a have a feeling it might. " +
		"If so, nodes created by splitting other nodes should probably be tagges. " +
		"I suppose.");
}

You too can reduce the tediousness of thinking before coding.  Here is a simple implementation of the exception, usable in any project:

public class ImTiredOfThinkingException extends RuntimeException {
	private static final long serialVersionUID = 1L;

	public ImTiredOfThinkingException(final String message) {
		super(message);
	}
}

Also, it totally shouldn’t be an exception…

A New Kind of Exception, 5.0 out of 5 based on 1 rating
  1. Totally working at the university Edsgar Dijkstra was working at when publishing that letter. []
  2. Totally talked with Kristen Nygaard. []
  3. Totally sat next to and discussed with David Parnas over beers at a conference dinner. []
Posted in: Uncategorized

1 Comment on "A New Kind of Exception"

Trackback | Comments RSS Feed

Inbound Links

  1. Fuuuuuuuuck! | Michael Westergaard's Homepage | December 1, 2011

Post a Comment