On Constants

I think constants are evil (just joking but….I will explain why).

I am tired of seeing a lot of Java classes filled with the same constants repeated over and over again, instead of collecting them in a common file, which in C Language was called include files (ooooah!).

Sometimes it is impossible to understand if they refer to the SAME concept (ipse in Latin) or to conceptually different but equal values (IDEM in Latin).

What is bad, I see constants used only one time and/or in one scope!

A one-use constant is probably a over-engineering: why defining it if you do not need in more then one place?

Also, a constant for something used in only two places is also a cognitive over-load for the reader: it must be a very good reason to use it.

Prefer a property value (defined via Java Spring) if you need a configurable one.
Prefer an enumeration class if you want to define the choices for the values.

Ipse dixit