Hello everyone!
I want to analyze typical code problems in Unity projects. Each one of us faced strange and unexpected code constructions in scripts, sometimes in legacy projects we need to support, sometimes in our own projects.
I want to understand a sources of this problems, and, maybe, make a guide how to awoid this - something like “How to make a good code for Unity”.
Can you share an examples of such code or such troubles (most exceptional sh[beep]tcode you saw in your practice)?
For example, what I faced in my practice:
- Totally incorrect usage of Unity. One company tried to make a mobile app for video editing using Unity, motivating this like “well, Unity is good for multi-platform apps, so we can shorten the time for development of interface for Android an iPhone using Unity”. And I don’t want to remember about how its code looked (you all may imagine how to edit video “between” Update() calls).
- Using “non-Unity-way”. Animating assets through code from MonoBehaviour without using Animator. Ignoring Unity tools (like, changing color of sprite through redrawing all of its pixels in memory). Forced usage of OOP principles and patterns in Unity projects, ignoring MonoBehaviour-based behaviour logic. Using MVC, inverted direct dependency injection and other techniques which is not utterly necessary in game projects. Making a code for Unity in a way used in other PL and stacks (Golang, Java, Fortran, you name it)… And so on.
- Overthinking and overdoing. That’s continuing of what I said about force usage of OOP - everything is abstract, making a code with 3 levels of abstraction and overloading bitshifting operators on simple demo with 3 moving objects
- Creating Unity over Unity. I.e., when developer has an experience from other stack and PL, and trying to make sort of a “wrapper” for “big an misterious Unity” for himself.
Also, I appreciate you to say your opinion about sources of such problems. What is the roots of this? How can developer avoid it?
(Sorry if I posted it at wrong forum. But I thought that it’s not only about code, but also about code quality, coding theory, and, we can say “way of thinking”. If it’s in wrong place please say or transfer it)