What's the right way to design code of your game?

I would focus less on designing all the code for the project ahead of time and more on just writing clean and flexible code.

You're going to run into a lot of issues with the game or design of the game when you start play testing and you need to be able to find alternative solutions and the flexibility to unplug systems and hook them back in elsewhere.

For example, if you start with the idea that monsters don't damage the player, but later decide to have monsters damage the player only when they collide, the amount of work to change it could be the difference between assigning the player to a new layer vs rewriting your enemy controller.

These are things you won't know until you play test and are deep into your planned/designed code structure which would then be a huge pain to rewire.

/r/gamedev Thread