Top 10 Lists of Common Java Mistakes (That Makes Top 100!)

Top 10 lists are very popular, fun, and informative to read. But there are so many of them! How to choose the right one? Here’s a meta top 10 list helping you find the top 10 top 10 lists. On a more geeky note:

SELECT TOP 10 mistake FROM source1
UNION ALL
SELECT TOP 10 mistake FROM source2
UNION ALL
SELECT TOP 10 mistake FROM source3
...

In this selection, I have carefully removed all of those top 10 newbie mistake lists that pop up when performing an average Google search. Because there aren’t 10 newbie mistakes, there are about one million. I’m more interested in subtle mistakes and problems. So, join me in reading these awesome 10 lists of top 10 Java mistakes / best practices (in no particular order)

1: ZeroTurnaround’s 10 Common Pitfalls of Experienced Java Developers & Architects

ZeroTurnaround has just released this one, in time for my post. The JRebel guys usually employ quite a geeky tongue-in-cheek, which I really like, of course:

http://zeroturnaround.com/rebellabs/watch-out-for-these-10-common-pitfalls-of-experienced-java-developers-architects/

2: jOOQ’s 10 Subtle Best Practices When Coding Java

Some advertising in our own cause. We have a top 10 list as well, about very subtle things that can go wrong when writing Java:

https://blog.jooq.org/2013/08/20/10-subtle-best-practices-when-coding-java/

3: AppDynamic’s Top 10 Java Performance Problems

AppDynamics is giving away this interesting and very well-written eBook for only your contact information. (Don’t blame me if they’ll call you and sell you their products after you download the nice list).

http://info.appdynamics.com/Top10JavaPerformanceProblems_eBook.html

4: The AmiableAPI’s Java API Design Checklist

This isn’t exactly a top 10 list, but more of a style guide helping you to write a good, clean API. Something that isn’t so obvious to do if you don’t write APIs every day:

http://theamiableapi.com/2012/01/16/java-api-design-checklist/

5: Josh Bloch’s talk about How To Design a Good API and Why it Matters

While this one isn’t labeled as top 10, it certainly contains the top 10 things to do when designing APIs, citing from a very authoritative reference: Josh Bloch himself:

http://www.youtube.com/watch?v=heh4OeB9A-c

6: Top 10 Mistakes When Writing Server-Side JavaScript Using Rhino

Haha, just kidding. There’s only one mistake here. It’s the fact that you’re writing JavaScript. So, on the the real #6:

6: Pierre-Hugues Charbonneau’s Top 10 Causes of Java EE Enterprise Performance Problems

This one is extremely well-written. A very good read for all Java architects out there:

http://java.dzone.com/articles/top-10-causes-java-ee

7: Top 10 Interesting Statements by Adam Bien About the Java Enterprise Edition 6 (JEE 6)

I like to cite Adam Bien. He’s very dogmatic, pro JEE Java Rock Star. While I most certainly don’t agree with him in many aspects, I still enjoy reading his blog. This list is not by Adam Bien himself, but by a Kai Waehner, who has summarised Adam Bien’s opinions quite well:

http://www.kai-waehner.de/blog/2010/09/10/10-interesting-statements-of-adam-bien-about-the-java-enterprise-edition-6-jee-6/

8: Top 15 Worst Computer Software Blunders

OK, this one isn’t about Java in particular, neither does it show concrete best practices. But why do we need best practices and avoid common mistakes? Yes, because things can go terribly wrong. Here’s how wrong they can go:

http://www.intertech.com/Blog/15-worst-computer-software-blunders/

9: Top 10 Java People You Should Know

You think this list is incomplete? Very unlikely. But you still might be interested in looking up the top 10 Java people, which have influenced our every day work like few others. They have said many things in their professional lives, which could fill many more top 10 lists. Here’s the “Top 10 Java People You Should Know” list:

http://javastoreroom.blogspot.ch/2013/05/top-10-java-people-you-should-know.html

10: The Top 10 List of Best Java-Related Top 10 Lists

And here’s a killer list explaining all about the origins of tail-recursion and – possibly – StackOverflowErrors:

https://blog.jooq.org/2013/11/01/top-10-lists-of-common-java-mistakes-that-makes-top-100/

10 Reasons not to Choose a Particular Open Source software

We’re all Software Engineers of one type or another. Most of us have one thing in common, though: We’re lazy. And we know that someone else was less lazy and has already solved that tedious problem that we’re on. And because we’re not only lazy but also stingy, we search for Free Open Source software.

But the problem with Open Source software is: There are millions of options for about every problem domain. Just look at web development with “modern” JavaScript. Which tool to choose? Which one will still be there tomorrow? Will it work? Will I get maintenance? New features? Plugins from the community?

While it is not so easy to find the right tool among the good ones (commons or guava? mockito or jmock? Hibernate or jOOQ or MyBatis?), it is certainly easier to rule out the bad ones.

Here are some things to look out for, when evaluating an Open Source software (in no particular order)

1. NullPointerExceptions, ClassCastExceptions

This is one of my favourites. It is very easy to google. No one is completely safe from these annoyances. But when you find stack traces, bug reports, investigate them closely.

  • Do they appear often?
  • Do they appear in similar contexts?
  • Do they appear in places where they could’ve been omitted?

It’s a matter of good design to be able to avoid NullPointerExceptions and ClassCastExceptions. It happens to everyone. But no NullPointerException should be thrown from a place that can be statically discovered by the Java compiler or with FindBugs.

Needless to say that the list of no-go exceptions thrown from a database library, for instance, can be extended with SQLExceptions due to syntax errors produced by that library.

2. Community Discussing Bugs instead of Features, Strategies, Visions

Every Open Source software has users and with Google Groups and GitHub, it has become fairly easy to interact with an OSS community.

For larger projects, the community also extends to Stack Overflow, Reddit, Twitter, etc. These next steps are a sign of popularity of an Open Source software, but not necessarily a sign that you should use them. Also, don’t be blinded by users saying “hey this is so cool”, “it just made my day”, “best software ever”. They say that to everyone who’s supporting them out of their misery (or laziness, see the intro of this post).

What you should be looking out for is whether the community is discussing visions, strategies, features, truly awesome ideas that can be implemented next year, in the next major release. It’s a true sign that not only the software will probably stick around, it will also become much better.

The converse to this is a community that mainly discusses bugs (see NullPointerException, ClassCastException). Unlike a “visionary” community, a “buggy” community will just create work, not inspiration to the vendor. But which one’s the chicken, which one’s the egg?

Another converse to this is a community that is disappointed by the false promises given by the visions of the vendor. I often have a feeling that Scala’s SLICK might qualify for that as it introduces an insurmountable language-mapping impedance mismatch between its own, LINQ-inspired querying DSL and SQL.

3. Poor Manual, Poor Javadoc

That’s easy to discover. Do you really want that? The best and most authoritative information should come from the software vendor, not some weirdo forum on the web that you’ve googled.

A good example are PostgreSQL’s Manuals.

A rant about bad examples can be seen here:
http://www.cforcoding.com/2009/08/its-time-we-stopped-rewarding-projects.html

Don’t be deceived by the idea that it might get better eventually. Poorly documented software will be poor in many other aspects.  And it’s such an easy thing to discover!

Of course, the “right” amount of documentation is an entirely other story…

4. No Semantic Versioning

Search for release notes and see if you’ll find something that roughly corresponds to semver.org. You will want patch releases when your Open Source software that you’re using in mission-critical software fails. When you get a patch release, you don’t want 50 new features (with new NullPointerExceptions, ClassCastExceptions).

5. Unorganised Appearance

Again, we’re in times of GitHub. The good old CVS times are over, where HTML was still used to share cooking recipes. Check if your Open Source software uses those tools. If they show that they’re using them. It will help you ascertain that the software will still be good in a couple of years if the vendor isn’t crushed by the mess they’ve gotten themselves in.

6. Vendor Side-Project evolving into an Offspring Product

Now that is a sign not everyone may agree upon, I guess. But after the experience I’ve made in previous jobs, I strongly believe that software that has evolved out of necessity before making it a product really suffers from its legacy. It wasn’t a product from the beginning and it has strong ties to the vendor’s original requirements, which doesn’t bother the vendor, but it will bother you. And because the vendor still has very strong ties to their offspring, they won’t be ready to make fundamental changes in both code and vision!

Specifically, in the database field, there are a couple of these software, e.g.

Note, I don’t know any of the above tools, so they may as well be awesome. But be warned. They weren’t designed as products. They were designed for a very narrow purpose originating from a pre-Apache context.

7. Generics are Poorly (or Overly) Adopted

Generics were introduced in 2004 with Java 5. Now that the heated debates about generic type erasure are over, generics are well adopted. Or aren’t they? The latest stable release 3.2.1 of Apache Commons Collections is still not generified! That must’ve been the number 1 reason why people had started shifting to Google Guava (or its predecessors) instead. There’s not much making for a lousier day than having raw types (or eels) slapped around your face.

The other thing that you should look out for, though, is over-generification. Generics can become really hard, even for top-shot Java architects. A common blunder is to strongly correlate subtype polymorphism with generic polymorphism without being aware of the effects. Having too many generics in an API is a good sign for an architecture astronaut. (or a design astronaut in this case). We’ll see further down how that may correlate with the person behind the design decisions.

8. Vendor Cannot Handle Objective Criticism or Competition

Here’s how to find out, who’s behind the Open Source software. While this isn’t important for a small, geeky tool, you should be very interested in the vendor as a person when looking for a strategic OSS addition, especially if you’re dealing with a benevolent dictator. The vendor should be:

  • Aware of competition, i.e. they’re doing marketing, learning from them. Improving to compete. This means that they are interested in being truly better, not just “convinced that they’re better”.
  • Open minded with their competition, with you as a customer, and ready to discuss various points of view.
  • Interested in new ideas, possibly putting them on a roadmap right away (but without losing focus for his main strategic roadmap).

Even if this is Open Source, there’s no point in being arrogant or conceited. The vendor should treat you like a customer (as long as you’re not trolling). Open-mindedness will eventually lead to the better product in the long run.

9. Vendor has no Commercial or Marketing Interests at All

Now, (Free) Open Source is nice for many reasons. As a vendor, you get:

  • Feedback more quickly
  • Feedback more often
  • Community (with pull requests, feature additions, etc.)
  • The feeling that you’re doing something good

True? Yes. But that’s true for commercial software as well. So what’s the real reason for doing Open Source? It depends. Adobe for instance has started opening up a lot, recently, since their acquisition of Day Software. All of JCR, JackRabbit, the upcoming JackRabbit Oak, Sling and Felix are still at Apache with the original committers still on board. But one can certainly not say that Adobe has no commercial interests.

OSS vendors should think economically and build products. Eventually, they may start selling stuff around their core products, or separate community and commercial licenses. And unlike they get too greedy (see Oracle and MySQL, vs RedHat and MariaDB), that can make commercial Open Source a very interesting business, also for the customer who will then get the good parts of Open Source (partially free, open, with a vibrant community) along with the good parts of commercial software (premium support, warranties, etc.)

In other words, don’t choose overly geeky stuff. But you might have recognised those tools before (poor documentation, no semantic versioning, poor tooling).

10. No Traction Anymore

To wrap this up, here’s an obvious last one. Many Open Source products don’t show any traction by the vendor. That goes along well with the previous point, where the vendor has no commercial interest. Without commercial long-term interest, they’ll also lose all other interest. And you’re stuck with maintaining a pile of third-party code yourself (fixing its many many ClassCastExceptions, NullPointerExceptions).

TL;DR : Conclusion

You should chose Open Source just like commercial software. Economically.

  • Open Source is not an excuse for bad quality.
  • Open Source is not an excuse for lack of support.
  • Open Source is not an excuse for non-professionalism.

If Open Source fails you on any of the above, the joke will be on you, the customer. You’ll get a bad product, and you’ll pay the price with exaggerated maintenance on your side, which you thought you’d avoid by chosing something free. Nothing is free. Not even Free Open Source. Ask the Grumpy Nerd