Reworking cumbersome game logic code

Started by
9 comments, last by Kylotan 16 years, 2 months ago
Quote:Original post by Zahlman
Quote:Original post by Kylotan
Some people may suggest moving to the State design pattern, but I don't think that solves your problem, just moves it.


He's trying to find the bugs; presumably he's not worried about the difficulty of fixing them (no "reworking" of "cumbersome" code can do that, except perhaps incidentally by causing a copy-paste error to vanish as redundancy is eliminated).


Could you elaborate on the point you're making here? I would think that moving to the State pattern in such a situation would not help at all, since you add a lot of scaffolding code that doesn't start to pay off until you get a lot more states. That would just obscure bugs rather than reveal them. The last thing you want when having trouble following existing code flow is to start sticking virtual function calls everywhere.

You also have to start worrying about the 'state' that is shared between 'states', which becomes more apparent when you move to the State Pattern but also more bug-prone to handle. Personally I would just stick with switch statements in a program like this until I understood enough of the problem to factor stuff out.

This topic is closed to new replies.

Advertisement