136

Today I saw this in our code base:
private static final int THREE = 3;

To do this:
rating += THREE;

I laughed, and cried a little.

Comments
  • 26
    Nope, we don’t use magic numbers here.
  • 3
    @bkwilliams wouldn’t this still count as a magic number 😏
  • 1
    @C0D4 yes, but it’s not a #DEFINE
  • 6
    Might be so developers don’t change the 3 to another number, but yeah, could’ve probably named the variable something more useful
  • 0
    @bkwilliams there is no #DEFINE in java
  • 5
    - no hardcoded values check

    - naming convention check

    - reusable code check

    - clean code check
  • 9
    Three = 4;

    Wonder what will happen next
  • 0
    Oh, blessing of static code analyzers. Or rather triumph of form over the content. Maybe next time you should read the value from resources?
Add Comment