Over-engineering the ammo UI?

Hi, I’ve been working with Unity for a while but still have a lot to learn in terms of best practices.

I had a think about how I’d implement the ammo UI before watching Rick’s solution, and instantly jumped to the idea of having the WeaponSwitcher fire an event whenever the current weapon changes, and another event on the Weapon class that gets fired whenever the current ammo changes. I’d then have a script attached to the ammo text that listens for those events and sets the text value accordingly.

I then continued the video and was amazed at the simplicity of Rick’s approach. I know there’s always lots of ways to achieve the same thing in programming, but would my idea be considered “over-engineering” in this situation? Would one approach be prefereable over another in certain situations, like in a larger project for example?

Hi Onnox,

First of all, good job on challenging yourself. :slight_smile:

Don’t worry if you do not come up with the perfect solution at the first onset. It is called game development. You reiterate a solution until you are happy with the result.

Rick does not develop the games from scratch in the videos. He spent a lot of time planning. He wrote bad code, made a lot of mistakes, just like everybody else. Then he revised his code, refactored it, replaced solutions, improved things, and so on. What you see in the videos is the result of a long process. You definitely don’t want to see Rick fixing bugs for hours or even days. :wink:

“Over-engineering” is normal. And sometimes, when you completed your complex solution, you suddenly get an idea how to simplify it. Was the original solution a waste of time? Absolutely not. You learn a lot by simplifying “over-complicated” code.

Is your approached “over-engineered”? I don’t know. Without seeing your solution and without knowing anything about your project, that’s impossible to tell. Whether something can be improved depends on the context and the requirements. A “large game” does not mean anything because “large” does not mean that the problem you solved in the “little game” is also “larger”.

To evaluate which solution solves your problem best, analyse your problem and compare the advantages and disadvantages of potential solutions. Don’t forget that you are not immortal. Time is also a crucial factor when deciding which solution is preferable. For this reason, we usually fix the problem first and worry about the solution only if there is a noticeable issue with the performance.

That’s just my opinion, though. Please feel free to ask our helpful community of students for further advice over on our Discord chat server. :slight_smile:


See also:

1 Like

Hi Nina, thanks for the thoughtful reply. I come from a software development background so I’ve been bitten by “technical debt” all too often, having to go back and do major refactoring, so that was my main worry. As long as I keep practising development in Unity, I’m sure the nuances of the engine will become second nature to me soon enough :muscle:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms