I have been working my way though the Player Actions that I had previously coded in one long if statement and am breaking each one out into its own class or function. So far I have the Move and Look functions done, and have started on the Use function.
One of the things that I have been playing with is Inheritance and trying to determine when two classes share enough of the same code that they should inherit stuff from a shared parent. One of the changes that I made was to make Rooms and your Inventory as children of a parent class called Containers. Basically, a Container is a place where you can take or drop things. The difference between a Room and your Inventory is that things can move about in between Rooms.
Friday, March 22, 2013
Monday, March 18, 2013
Refactoring!
I'm not sure what inspired me to code for entertainment after a year and a half of nothing. I suppose it doesn't really matter, though. What is important is that I coded for many hours this weekend. It felt good to get back into the swing of it.
I went back to my silly SneakOut text adventure game. The game is not particularly brilliant, but I think its a good exercise for me to finish it. Anyway, looking back on that code, man, was it horrible.
I've been doing some programming for work over the last couple of months, and by that I mean code that people actually look at and give feedback on, and that has improved my understanding dramatically. So, when looking at what I had written on my own 18 months ago, it was surprising at how mismanaged everything was.
Therefore, I spent all my time refactoring the old code into something more sleek and understandable. Instead of several huge classes, things are becoming broken out into bite sized chunks and I think I am eliminating some unnecessary repetitive code as well.
Anywho, I have no idea if I will continue this coding routine, but if i do, i'll make sure to keep blogging for my future self to look at fondly.
I went back to my silly SneakOut text adventure game. The game is not particularly brilliant, but I think its a good exercise for me to finish it. Anyway, looking back on that code, man, was it horrible.
I've been doing some programming for work over the last couple of months, and by that I mean code that people actually look at and give feedback on, and that has improved my understanding dramatically. So, when looking at what I had written on my own 18 months ago, it was surprising at how mismanaged everything was.
Therefore, I spent all my time refactoring the old code into something more sleek and understandable. Instead of several huge classes, things are becoming broken out into bite sized chunks and I think I am eliminating some unnecessary repetitive code as well.
Anywho, I have no idea if I will continue this coding routine, but if i do, i'll make sure to keep blogging for my future self to look at fondly.
Subscribe to:
Posts (Atom)