Refactoring and keeping it DRY
The Don’t Repeat Yourself (DRY) acronym is the software developer’s conscience: it tells you when you’re in danger of making a bad or questionable decision, and gives you a feeling of satisfaction after a job well done.
In practice, repeated code is part of programming life. Trying to avoid it by constantly thinking ahead will put up so many roadblocks in your project that it won’t seem worthwhile carrying on. A more efficient—and sane—approach to dealing with repeating code is to quickly identify it when and where it occurs and then look for the best way to remove it. This task is called refactoring, and our GameBehavior
class could use a little of its magic right now.
You may have noticed that we set the progress text and timescale in two separate places, but we could easily make ourselves a utility method to do this for us in a single place.
As you get more comfortable with programming...