My thoughts as an enterprise Java developer.

Wednesday, August 10, 2016

Tight scoping of constants

How do you declare constants that are only needed in a small scope (function or smaller)? I declare them in the tightest scope as final with an all-caps name. I.e.:

final int THRESHOLD = 1000;

That coveys the intent that it is a constant but minimizes scope.

No comments: