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*

3
  • 2
    what happens when some moron changes Const.PERIOD to be equal to ~? There is no justification for a tautology of named characters, it just adds maintenance and complexity that is uneeded in modern day programming environments. Are you going to write a suite of unit tests that basically say assert(Const.PERIOD == '.')? Commented Jul 6, 2016 at 17:54
  • 3
    @JarrodRoberson - That would suck, sure. But you'd be in just as much trouble if someone added a Unicode constant that looks almost exactly like a comma rather than an actual comma. Like I said, this isn't the sort of thing that I'd do in a greenfield development project. But if you have a legacy code base with a spotty test suite where you've tripped over the comma/ period or apostrophe/ Microsoft abomination apostrophes issues a couple times, creating some constants and telling people to use them may be a reasonable way to make the code better without spending a year writing tests. Commented Jul 6, 2016 at 17:58
  • 3
    your legacy example is a poor one, I just finished refactoring a 1,000,000+ LOC code base that is 18 years old. It had every printable character defined like this multiple times with different conflicting names even. And many times things named COMMA were actually set = SPACE + "," + SPACE. Yes some idiot had a SPACE constant. I refactored them ALL out and the code was orders of magitude more readable and college hires were much more able to track things down and fix them without having 6 levels of indirection to find out what something was actually set to. Commented Jul 6, 2016 at 18:02