Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

14
  • 11
    I'm curious, why would you believe it to be bad style to change these? Commented Jan 8, 2018 at 13:58
  • 36
    Unless you are modeling physical properties with constants that have known mathematical values, everything can change at some time. Commented Jan 8, 2018 at 14:04
  • 19
    software is soft. Commented Jan 8, 2018 at 15:58
  • 10
    @GregT I would disagree. final gives you a compiler-enforced guarantee that the program won't modify the value. I wouldn't dispense with that just because the programmer might want to modify the value assigned in the source code. Commented Jan 8, 2018 at 18:24
  • 10
    Not much time to articulate a full answer, but I suspect your colleagues concern isn't so much with constants, but with the code-inlining of configuration values, which might tend to manifest as constants. ... Constants protect you against stupid mistakes, like accidentally assigning over gravity mid-game/run. They don't necessarily mean, gravity is the same on every planet ... That said, the healthy solution is to make gravity a constant, but pull it from a planet file or database at the start of the relevant scope. Commented Jan 8, 2018 at 21:02