void C_Map::save(char *filename) {
ofstream saver (filename,ios::binary);
saver<<_xsize;
saver<<_ysize;
MAPLOOPXY
saver<<_mapdata[_xsize*y+x];
}
}
saver.close();
}
Now, if you don't see what is so horrible about this particular piece of code, please, stop reading my journal now, and leave. Now, the author of this particular piece of code gave the following excuse, when confronted with my shocked statement... " MAPLOOPXY is just a little timesaver" A what? A timesaver? I look at that code and I see a syntactic nightmare. You have a macro that creates two for loops (just a guess here) using two counters that are declared...somewhere. Not only that, but then this macro generated loop produces two temp variables x and y... talk about code that you can't maintain. How on earth would you know, if initially reading the code, that MAPLOOPXY use _ysize, _xsize or for that matter, produce the temps x and y. You wouldn't. Not only that, but you would notice that there are two entirely out of place closing braces... Jesus...talk about something to kill someone over. He then continued on saying: " i use the same look about 6 times in the same file for different functions". To which Oluseyi responded: " davw, then refactor or, as Washu would say, "Refactor, bitch!" Damn right, refactor. People wonder why many of us post against macro usage in C and C++ applications. Well, now you know why. Because people inevitably think to themselves: "Well gee if I do this it will be a time saver." But they don't actually consider the consequences of such actions, such as the ability to intuitively understand the code. So, in my own words, refactor bitch.
Anyways, next entry we'll continue on with our refactorings.