In game industry, especially in Engine side, where efficiency is the top concern, and changes seldom occur, code like this makes sense. But in term of GUI, and /or Control, you are right, there is no need to write code in such a way.
Again, in industries such as gaming, in an MVC (Model-View-Control design pattern), codes in Model are always of speed concerned. But in term of View, and Control, where flexibilities, extensibility and maintainability are always the top priorities, it's discouraged to write code that way.
As a matter of fact, the code segment in question was a varied form from an interview question for many game companies a few years back.
Again, in industries such as gaming, in an MVC (Model-View-Control design pattern), codes in Model are always of speed concerned. But in term of View, and Control, where flexibilities, extensibility and maintainability are always the top priorities, it's discouraged to write code that way.
As a matter of fact, the code segment in question was a varied form from an interview question for many game companies a few years back.