Winston Gutkowski wrote:...you should be concerning yourself with the semantics of that problem, and not bits and bytes - in my (I'm sure by now, nauseating) terminology: the "what", not the "how".
To my mind a constant is something that is set at creation time and cannot be changed - ie, it either doesn't exist, or it has a fixed value - which further suggests to me that, whatever it is, it's immutable.
It does, however, have scope. A static final field in a class, or an Enum instance, is likely to "live" for as long as the JVM that loads it exists; but a final field in a class will live for as long as its associated object does. I'd categorise both as constants; just at different levels
- and of course, with different naming conventions.
"Il y a peu de choses qui me soient impossibles..."
Stevens Miller wrote:My personal view is that managers seem to think "what" is very important, mostly because they don't know "how," while programmers who work for them are the ones who know "how" to do the "what." "How" is what I'm doing here.
A static final and an instance final have different naming conventions. That's canon, and I have no quibble with it. I am asking about two constants that are both static final, both of which are immutable for a given JVM time, but only one of which was set at compile time. For the constant set at compile time, I am satisfied that ALL_CAPS is the convention to use. For the static final that was not set at compile time, but is set for a given JVM time, what convention do you propose?
Stevens Miller wrote:There are some magnificently abstruse papers on this, most of which I don't understand, that all seem, in the end, to ignore the fact that "what" I want to do is a goal, and "how" I do it is the means to reach that goal. You can have all the "what" you want, but you get nowhere without the "how."
To my mind a constant is something that is set at creation time and cannot be changed - ie, it either doesn't exist, or it has a fixed value - which further suggests to me that, whatever it is, it's immutable.
Sure. That's what "final" means, right?
My "constants" both endure for the life-time of a loaded JVM (let's call that "JVM time"). One happens to have been set at compile time, the other is subject to change after compile time but is fixed for a given JVM time. Thus, both are static final and both are fixed for a given JVM time.
A static final and an instance final have different naming conventions. That's canon, and I have no quibble with it. I am asking about two constants that are both static final, both of which are immutable for a given JVM time, but only one of which was set at compile time. For the constant set at compile time, I am satisfied that ALL_CAPS is the convention to use. For the static final that was not set at compile time, but is set for a given JVM time, what convention do you propose?
Stephan van Hulst wrote:For Java, a convention that makes a lot more sense to me is to write all static variables in all caps. I think that would clearly convey "here be dragons".
"Il y a peu de choses qui me soient impossibles..."
Stephan van Hulst wrote:
Stevens Miller wrote:
Winston wrote:To my mind a constant is something that is set at creation time and cannot be changed - ie, it either doesn't exist, or it has a fixed value - which further suggests to me that, whatever it is, it's immutable.
Sure. That's what "final" means, right?
Not to me, and I imagine not to Winston either. The final keyword can be used to make a variable's value constant. For a reference type, that means you can not make the variable point to a different object, but it doesn't mean that you can't change the object itself, something we're usually much more interested in.
"Il y a peu de choses qui me soient impossibles..."
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |