
The best code separates concerns.
For example the Player class shouldn't update the UI directly, instead it should fire an event which in turn the UI script should listen to it and do whatever it needs to do.
Separating the UI from the underlying logic is one of the best (and also slightly easiest) things you can do to keep your code quality high. Ideally your game should be able to compile and work just fine without any UI at all, because none of the logic scripts should depend on the visual interface.
Another example, if you have score in your game, it shouldn't be the Enemy class' responsibility to increase the score when an enemy dies, instead it should fire off an OnAnyEnemyDiedEvent which some kind of ScoreManager should listen to in order to update the total.
Decoupling is one of the best things you can do to keep your code quality high. It keeps things smaller so you don't have to maintain a huge amount of data in your brain's working memory as you're building something.

English



