3 ms·
There is a difference between "real constants", like the value of pi, and "runtime constants or almost-constants", such as "liftoff time" in software that runs
by inglor_cz 6y ago
There is a difference between "real constants", like the value of pi, and "runtime constants or almost-constants", such as "liftoff time" in software that runs onboard a rocket going to space. While preparing for launch, the latter value may be changed, but once the vehicle is on its way, it becomes a constant until the end of mission.
It would be nice to protect such variable from modification, "lock its value" somehow.
- sgt101 6y agoWell, OO folks would say : Enapsulate it in a class which contains a check for lift off and a value change method. I would say "yes it's nice, but it's also complex and you are just as likely to inject a bug by doing this as you are to prevent a failure". (although for this example I think it isn't a bad idea really)
- mikewarot 6y agoI have no idea what the heck is going on with objects in C++, it makes no sense to me. The model in Delphi/Lazarus/Free Pascal has always seemed quite natural to me since I first encountered it.