Exceptional coding style

Walter Bright newshound2 at digitalmars.com
Mon Jan 14 12:36:52 PST 2013


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.



More information about the Digitalmars-d mailing list