Mech Retriever Dev Blog
It’s important to restructure your code as you go–partly because the code you don’t write is important.
For example, a lot of times it makes sense to have your code throw exceptions when it encounters a bad state. But if you can, it’s always better to make it so the code cannot enter that state, so that you don’t have to worry about the condition in the first place.
This is primarily driven by object design–specifically, how you design the “public interface,” or variables and methods that other objects can see, though internal implementations can affect it too. For example, when I changed the BattleScreenDriver to use one View per player instead of using one View for all, I no longer needed to supply a player argument for commands to the driver (e.g. Move) and so didn’t need to check to make sure players didn’t call moves out of turn.
A weird mantra I almost espouse sometimes is “try to avoid writing code,” which seems odd for a developer to say, but what I really mean is that you should try to avoid writing unnecessary code.