4 ms·
> The negative drawbacks of extracting constants is typically minimal > ASCII_A It comes down to naming and purpose. The example, ASCII_A, is terrible becaus
by sheepmullet 9y ago
> The negative drawbacks of extracting constants is typically minimal
> ASCII_A
It comes down to naming and purpose.
The example, ASCII_A, is terrible because it doesn't describe the purpose with its name.
What will end up happening in any large codebase is ASCII_A will get reused in dozens of different places for dozens of different reasons.
If it was named minValidLetterForAlgorithmX it would convey intent and its more likely to be used correctly.
- Terr_ 9y agoI'm partial to ALPHA_START or FIRST_LETTER. While it's true that 'A' is both, the naming helps communicate that the context is range-testing for alphabets inside a larger character set.