For a long time I believed placing a constant below the private method actually made it private. Then I set a 'private' constant in a class where was no reason to use that constant outside of the class... But naming is hard and memory is not perfect so I used the same constant name elsewhere. I forgot it existed as a not 'private' constant in another class. Bang!
The principle of least surprise should apply whenever possible.
Mitch Kuppinger
Parent (Grand), Physician, Programmer
For a long time I believed placing a constant below the private method actually made it private. Then I set a 'private' constant in a class where was no reason to use that constant outside of the class... But naming is hard and memory is not perfect so I used the same constant name elsewhere. I forgot it existed as a not 'private' constant in another class. Bang!
The principle of least surprise should apply whenever possible.
Thank you for re-raising this.