Ben's blog
Software development, games, and all that jazz
Home
Archive
Posts
Pages
Search:
Edit Post
Title:
Body:
<p>Now that I've had a few days to do things other than search for jobs or flats, I'm getting back into the swing of development again, and really quite enjoying it. I've had an epiphany of sorts and seem to be able to actually program really quite well, as big-headed as that sounds.</p> <p>Previously I'd be able to write code to do all sorts of stuff, but after a while it'd start getting tangled up with itself, surrounded by unnecessary crud, and development would grind to a standstill until I could be bothered to press delete and start again, with that little bit more experience.</p> <p>I took a look over the code of CITS and decided something had to be done - there were ugly dependencies everywhere, lots of huge objects and massive methods, things had far too many responsibilities and so on and so forth. Most of the rules of good design had been broken (consciously, as I figured they wouldn't matter on a small project). Adding a new building would have been a tremendous amount of work, let alone finishing the thing.</p> <p>Now though, something has clicked and I'm refactoring like a beast (beasts are good at refactoring, I've decided). After not very long I started making small changes here and there, making sure I didn't break anything and kept it running identically as I went. First thing was to separate out the graphics code from buildings into a "building graphics" component, which went well. Then I separated out the physics in a similar way. Then I tidied up the building class, and re-arranged the dependencies of all the other classes to depend solely on the specific bits they needed. After each change, however small, I'd compile and run it to check that things were working, then check the code in to the newly set up SVN repository. As I went, classes got more focused and small, dependencies started to make sense, the code got cleaner in general and compile times were reduced significantly. Dare I say it, the bits that I've touched up are actually really quite good now. Refactoring is fun :)</p> <p>Things aren't perfect of course; there are plenty more areas to refactor that are going to be a little more difficult (for example, the low-down bits of the island's physics depend on low-down bits of its graphics, since the physical representation of the island is built from the contents of the vertex buffer). Also, I kind of wish I had started off with good practices at the very beginning - it would be great to have a full suite of unit tests to ensure correct functionality rather than having to run the game every change, and an issue tracker would be very useful. <p>Anyway, the short of it is that CITS is back on track, and once I've sorted out these slightly more tricky refactorings I'll be back to adding functionality and pumping out pretty screenshots for you people :) Don't be surprised if the new job and the move get in the way of things though!</p>
Tags:
cities-in-the-sky
Body markup:
Plain Text
Textile
HTML
Markdown
ReStructuredText
Draft: