If there’s one thing that really annoys me, it’s opening code with garbage like this in it:

Set foos = new HashSet<foo>();
String queryString = "from FooTable as foo where foo.barField in (:listOfBarFields)";
try
{
	foos.addAll((List<foo>) HibernateSessionFactory
			.getSession().createQuery(queryString)
			.setParameterList("listOfBarFields", getBars()).list());
}
catch (Throwable th)
{
}

First, all the method chaining kinda bugs me — but I can live with that.

What makes me want to barf is chaining all those Hibernate calls together in one statement, and surrounding it with a try/catch that eats Throwable. Throwable. This is not framework code, this is not a library — it’s application code, and application code has no business catching a raw Throwable. And to make it worse, it completely suppresses the Throwable and makes it look like it never happened - it doesn’t even log it.   Oh, and there’s no JUnit test covering the code.

Anyone who writes code like this should be cruelly and severely punished. Or fired.

What’s also sickening is that anyone can write this kind of stuff and call themselves a professional programmer (and lots of them do it all the time), but you need a state license and show some level of competency to give a pedicure, run an auction house, or be an interior designer.

3 Responses to “Code that makes me vomit”
  1. huikau says:

    Yea, yea… forget all that, take a look at the curly placement!!! That is just plain silly! :)

  2. JavaRant.com says:

    Looks very familiar! Hork! Too bad you can’t chain the Throwable to the calls somehow. :)

  3. matthewtap says:

    … but have you ever thought about how hard it’d be to make that little toe-nail on the little toe look ‘pretty’. That’s some care and craftsmonship one just can’t appreciate enough. All I can say, is that it’s a good thing we’re paying to apprentice more of them in high school so they can build their skillcraft sooner.

Leave a Reply