Exceptional coding style

monarch_dodra monarchdodra at gmail.com
Mon Jan 14 12:57:25 PST 2013


On Monday, 14 January 2013 at 20:36:51 UTC, Walter Bright wrote:
> On 1/14/2013 11:52 AM, Ali Çehreli wrote:
>> On 01/14/2013 11:24 AM, 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
>>>
>>>
>>
>> Here begins another epic thread. :)
>>
>> I haven't read the article but came across this: "I personally 
>> enforce the rule
>> that all method names should begin with a verb unless they 
>> can't." The author
>> adds that he prefers getLength() to length().
>>
>> That rule is misguided because not every member function 
>> represents an action;
>> there are also attributes. Attribute methods should be nouns, 
>> in D or in C++. In
>> our C++ code we simply say length() (and setLength() if 
>> needed).
>
> Well, not everyone will agree with everything he says. But it 
> is interesting, and a number of the conventions in there are D 
> features.
>
> I also found it interesting how some of the conventions used 
> defies generally accepted C++ best practices.

Apart from a few *style* issues, the only thing the article 
contains was mostly hate for the stl.

I understand one might dislikes the stream operators due to the 
syntax (myself included), but once you've used them more than 
once, and know how to use them, they aren't a problem. The strong 
typing they provide is simply unmatched in C++. The article even 
mentions that NOT using stream operators was one of their biggest 
source of bugs. And Carmack himself replies stating that in 
retrospect: StrongTyping > WeirdCode.

There's also hate for stl's containers, stating they are *too 
generic*, stating that it is better to use *Only* a HashTable of 
<int, int> or <char*, int>. Nobody is stopping you from doing it 
with the stl. Not being overly generic is one thing. Not using 
something specific because it *spawned* from something generic is 
another.

The argument is *always* the same "the syntax is ugly and hard to 
use and outside of my comfort zone".


More information about the Digitalmars-d mailing list