Why do some experienced programmers write comparisons with the value before the variable?

That used to be the case, yes. Of course, nowadays almost all compilers warn about assignments in if() conditions, so the advantage is only there for people who routinely suppress warnings.


Yes, that's correct. It's to detect the typo of = instead of ==.


This has been dubbed as a "Yoda Conditional"!

See here https://stackoverflow.com/questions/2349378/new-programming-jargon-you-coined

I really like that term because:

if(Light::On == light)

Reads as:

"If on is the light"

As stated already, this is used to prevent incorrect assignment. It could be argued that this practice is archaic based on modern IDEs but I still think it is good practice.