Exceptional coding style

Stewart Gordon smjg_1998 at yahoo.com
Mon Jan 14 16:55:24 PST 2013


I seem to be managing to hit the "Reply" button instead of the 
"Followup" button more often than is desirable.  (What happened to the 
days when "Reply" meant "Followup" in newsreaders?)

On 14/01/2013 19:24, Walter Bright wrote:
> Quite a nice read on the coding style used in Doom.
>
> http://kotaku.com/5975610/the-exceptional-beauty-of-doom-3s-source-code?post=56177550

Am I the only one who expected, on seeing the subject line, something 
about a coding style that relies heavily on exceptions?

But I agree with most of the points made.  Make code self-documenting. 
And compact, but not at the expense of readability.  Sometimes I see 
code that doesn't seem to be intended as an IO*CC entry, nor an attempt 
to "protect" the code or squash it into as little space as possible for 
release, and yet is so obfuscated that I don't know how the maintainers 
manage to maintain it (let alone decide against deobfuscating it).

I also noticed this:

"Removing a value from an std::vector is dumb too:

vec.erase(std::remove(vec.begin(), vec.end(), val), vec.end());

Gee, that's going to be typed correctly by every programmer every time!"

It seems that even the writer of that piece hasn't typed it correctly - 
from what I can make out, that code would remove everything _except_ val 
from vec.  Either that or it wouldn't work at all, since the vector 
returned by remove is no longer a plain vector iterator.

(Moreover, any clue what possessed the author of that piece to make 
every code sample an image, thereby destroying accessibility and making 
it impossible to c&p?)

And it isn't clear what he means by "real tabs"....

Stewart.


More information about the Digitalmars-d mailing list