Various technical articles, IT-related tutorials, software information, and development journals
Thursday, August 8, 2013
Refactoring by Compiler Errors
The class that holds information about running games for a game server I'm developing had separate boolean fields to keep track of things like "is the game open to new players", "has everyone selected their character", and "has gameplay actually started". I realized that I could replace these variables with a single enum value because the statuses always follow the same order. There are quite a few places in the application that check those fields, so it would have taken me a long time to find and update them all. However, I just went ahead and deleted those fields, causing compiler errors when I attempted to build. With the list of compile-time issues, I was able to quickly navigate through the project and make minor changes to use the enum. So, instead of creating a list of things that you'll need to fix before an update, just go ahead and change the fields. You'll see exactly what needs changing.
Labels:
hl progamming
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment