[bind10-dev] BIND 9 style guidelines
JINMEI Tatuya / 神明達哉
jinmei at isc.org
Wed Sep 2 01:38:02 UTC 2009
(finally coming back to the BIND10 development world:-)
At Mon, 31 Aug 2009 16:25:19 +0200,
Shane Kerr <shane at isc.org> wrote:
> In some of our various discussions we have noticed that we need to
> document our style guidelines. As a starting point, I suggested we begin
> with the BIND 9 style guidelines. I have put these on the Trac site:
>
> https://bind10.isc.org/wiki/BIND9CodingGuidelines
>
> I'm not sure why these are not shipped with the BIND 9 code - I had to
> pull these from CVS.
We'll also have C++ specific style issues. I guess the style
guideline for other C++ based projects will help. Some examples:
Mozilla: https://developer.mozilla.org/en/Mozilla_Coding_Style_Guide
XORP: http://cvsweb.xorp.org/cgi-bin/cvsweb.cgi/xorp/devnotes/coding-style.txt?rev=1.7;content-type=text%2Fplain
Here are a few points I wondered in my prototype experiments:
- File suffix: .cc vs .cpp, .hh vs .h
- Naming convention (especially) for class members. There seems to be
two popular variants:
+ all lower cases, concatenating "sub words" with underscores.
e.g. to_text()
+ begin with lower case, and each following word capitalized.
e.g. toText()
(In the experimental code I wrote I was inconsistent:-)
- Whether to use an underscore (especially) for private member
variables, e.g.
private:
int type;
//or
int _type;
Evan said our previous consensus was not to use underscores. I'm
fine with that if that's the consensus, but there is a case I'd
particularly like to use this style: in a member initialization
list:
class Foo {
public:
Foo(int type) : _type(type) {}
private:
int _type;
};
Here, if I don't use an underscore for the member variable, I need
to rename "type" as the function argument name:
Foo(int type) : type(type) {} // this doesn't compile
Of course, we can easily find an alternative name e.g. arg_type,
etc, so it's just a matter of convenience.
---
JINMEI, Tatuya
More information about the bind10-dev
mailing list