Constant Encounters
[Nov 2017] It is hard to find a sizeable piece of code that isn’t peppered with constant values, yet it doesn’t get its proportional attention or necessary scrutiny. Most developers use constants to hide magic numbers and global data from inline repetition. Like the intent, the implementation styles are rooted in convenience too. In the Swift world, I have seen developers storing constants as static properties on value types and even enumerations. Java developers, having lesser options, tend to use static properties on stateless classes or even abstract classes. Why? The reasons I have heard ranges from it’s performant to there are no better places for it. I wish they could see it through the Object-Oriented lens as to how absurd that is. Just use an object. It’s that simple.
Comments
Post a Comment