A New Kind of Exception

 

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

VN:F [1.9.17_1161]
Rating: 5.0/5 (1 vote cast)

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. []
 

Tags:

 
 
 

1 Comment

     

    Leave a reply

    required

    required

    optional


    On my mind…

    • For a status report, I had to figure out how much code I'm maintaining. Turns out it's roughly 390000 lines.
      7 days ago
    • This is becoming a bad habit: had to run to catch the last direct train to Eindhoven.
      8 days ago
     
     

    Recent Comments

    • Michael: Forgot to add: in my code in the post, what I'm trying to do is just to get all …
       
    • Michael: Yeah, unless you know you are processing an integer, you can only get an object …
       
    • Danny: Hmmm... is the first solution you explain that much different from the original?…