Anyhow, back to the code. I noticed such troubling snippets as this:
void Score::WriteScore (Score score)
{
// Write the scores on screen
WriteText("Score: ", 7, 10, 700, 14);
WriteText("Score: ", 7, 900, 700, 14);
char *s = new char[9];
s = itoa(score.UScore, s, 10);
WriteText(s, strlen(s), 55, 700, 14);
s = itoa(score.CScore, s, 10);
WriteText(s, strlen(s), 945, 700, 14);
}
Magic numbers, using char * where std::string is much more suited, itoa where a std::stringstream might be better, and (most troubling of all!), a memory leak. All in just 7 lines!! The perils of being a self-taught programmer, you see. The date on the file suggests it was written just under 3 years ago, and by that measure I've improved by leaps and bounds - I've gone from a poor programmer to an average one. At this point, I'm more or less able to write visually clean code, and avoid the majority of beginner-mistakes (about time!). This has led people to remark that I am a good-enough programmer, because my code looks nice enough, neatly indented with fairly detailed documentation and flashes of good habits. Yet this is very superficial, because under the hood it's a different story: design-wise, my brain doesn't seem to be able to handle complex problems. The same people who give me encouragement would probably run away if they'd seen some of the terrible monstrosities I've coded, and the truly apalling ways I've "debugged" pieces of code.
Of late, I've lost the interest in programming that I used to have a long time ago. I slowly feel like it's returning, albeit with a regret that I've wasted so many years when I could've improved even further, and made up for any inherent limitations I have when it comes to making up a design. After a good year or so, I took out the Python book I've had my eye on, and have started to dip my feet into the strange world of quasi-functional programming. Let this blog be a reference with which I can gauge my progress.
2 comments:
self taught programmers are kinda worrying. you haven't seen stew's flying tank program code that he made in year12 (and you don't want to!)
"self taught programmers are kinda worrying."
Hmm, thanks for the encouragement! :) So I'm not the only one who thinks I'm a hopeless case when in comes to programming ;) And to think I was mentoring your year, 'twas shameful.
Post a Comment