CodeSOD: Magically True

Matt P was spending a few hours trawling through a Java code base, working through the poorly documented logic and the bugs and the odd conventions. It was the kind of code base that rightly eschewed "magic numbers", favoring constants, but was also the kind of code base which took that to an extreme which arguably didn't help readability.

For example:

protected static final boolean BOOLEAN_TRUE = true; protected static final boolean BOOLEAN_FALSE = false;

It's no file not found, but it's important that we clearly define what we mean by true.

[Advertisement] Otter - Provision your servers automatically without ever needing to log-in to a command prompt. Get started today!

This post originally appeared on The Daily WTF.

Leave a Reply

Your email address will not be published.