[openbeosnetteam] Re: question about coding style

  • From: "Axel Dörfler" <axeld@xxxxxxxxxxxxxxxx>
  • To: openbeosnetteam@xxxxxxxxxxxxx
  • Date: Tue, 25 Jul 2006 20:55:19 +0200 CEST

Hi Oliver,

Oliver Tappe <openbeos@xxxxxxxxxxxxxxx> wrote:
> On 2006-07-25 at 16:08:30 [+0200], Axel Dörfler <axeld@xxxxxxxxxxxxxxxx> 
> > wrote:
> > Well, we're following the Be style too :)
> > C structures and methods are lower case with '_', while C++ classes 
> > are
> > UpperCaseAndCombined. C structure members are lower case, too, 
> > while C+
> > + members have the 'f' prefix. 
> Ok. So would it be ok to change udp.cpp from the C-style to the C++-
> style? I 
> mean udp_protocol is a C++ struct, although it inherits from a C-
> struct. A 
> bit of a mixture, really.
> Would you object to me using UdpProtocol instead of udp_protocol (and 
> of 
> course then use the f-prefix for struct members)?

I would say these are corner cases in the style guide, and should be 
used as preferred by the actual developer.
Now, I can just give you an insight into the logic I am following here, 
maybe it appeals to you to, maybe not - see below :-)

> > > -    method declarations should be lined up (with lots of space 
> > > to the
> > > left)
> > Not sure what you mean here.
> I mean this:

1)
> struct udp_protocol : net_protocol {
>                   udp_protocol();
[...]
> };
>
> instead of that:
2)
> struct udp_protocol : net_protocol {
>     udp_protocol();
[...]
> };

AFAICT there is no part in the style guide that would actually 
advertize 1) over 2). In fact, I think that only 2) is specifically 
mentioned, and we only came up with 1) because some developers 
preferred this - and it's sometimes really clearer, too, IMO.

> > Yes, the OpenTracker style guide doesn't include the C case. When 
> > you
> > look at the Be headers, the C naming style seems to be consistent, 
> > but
> > also different from the C++ naming style.
> Yes, both are consistent, but we seem to be using C-style in .cpp 
> files and 
> that confuses me (network/stack/stack.cpp is an example).

Since you always have to deal with C-structures in C++ files, I am 
following a logic to use either the C or C++ naming style in C++ files:
If the struct is a dumb struct with all of its members public, and no 
real logic attached to it, I'm using the C style. If it has its own 
logic that it hides from others, I'm using C++ style. However, I'm 
naming methods always in the C++ style, which the few Be examples 
(entry_ref, ...) don't do.

Bye,
   Axel.


Other related posts: