Common Red Flags in Java Development

About Dustin Marx

In several years of developing, reading, reviewing, and maintaining hundreds of thousands of lines of Java code, I have become accustomed to seeing certain “red flags” in Java code that often (but perhaps not always) imply problems with the code. I’m not talking about practices that are always wrong, but rather am talking about practices that might, in limited circumstances, be appropriate but generally are a sign of something wrong. These “red flags” may at times be innocent, but often warn of an inevitable “heap of hurt” that is inevitably coming. Here I summarize some of these and briefly discuss situations in which they might be okay as well as describing why they typically are not okay.

Many of these “red flags” are significant enough to warrant warnings from code analysis tools such as FindBugs. The popular Java IDEs flag many of these as well. However, I have seen developers miss these more literal flaggings from these tools and IDEs either because they had the options turned off or because they had, out of habit or because not understanding the risk associated with the flag, ignored the warning.

Use of == (rather than .equals) with References


Source : http://www.javacodegeeks.com/2013/06/common-red-flags-in-java-development.html

Back to Top