A day later the Java guy got back to me with a full blown Java project three levels deep which was just a translation of my ~30 lines of Python, and it “didn’t work”. I had to read what was now hundreds of lines of Java to find 3(!) bugs in it.
That day I realized FizzBuzzEnterpriseEdtion is much closer to reality than I thought.
As is, the only way I'd approve of it is if it was required to have the value be addressable. I'm not sure how often of a concern that is in java, but in Go for example, from ~1.3 to somewhat recently sticking an integer in a interface would cause a small allocation to hold the integer. By having it stored as a variable (you can't take the address of a constant in go) one could elide the allocation by storing the address of the variable in the interface instead of it's value. Of course now go will automatically do that for small values (N < 256).
That's a pretty niche use, but it does exist. I'll assume it's not novel, and there are other, perhaps similar use cases for having a symbol instead of using the literal.
wrt https: Yeah, it should be in muscle memory, but humans make mistakes, fat fingering is a thing. Using a symbol can give you a compilation time check. Of course, you may typo the symbol and have the exact same problem. The ability to compare by address actually applies more to strings though, since you can check the address & length for equality rather than having to do a full comparison of the string. This may or may not be an issue in any given language/implementation based on a variety of reasons (string interning, multiple definitions of a literal due to runtime/dynamic loading).
assert(INT_1 == 1);
Gotcha. class MyBetterrrrInteger(MyCustomNumberClass) implements ICalculatable {
public static MyBetterrrrInteger(OtherIntegerClass num) {
...
// oh did I forget to add generics to the mix? damn.
}
...
}https://www.gnu.org/software/hello/
For a while I did not clue in to the fact that they were serious, I thought they were making fun of their own build tools...
In fact, I came across a line of code that was basically `two = 2;` in my own company's codebase just a few days ago.
https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris...
Things like this:
I've actually seen production code with: