[pedevel] Re: Style of constants?

  • From: Oliver Tappe <pedevel@xxxxxxxxxxxxxxx>
  • To: pedevel@xxxxxxxxxxxxx
  • Date: Tue, 17 May 2005 16:32:59 +0200

Sorry, I forgot about this one...

On 2005-05-15 at 20:12:35 [+0200], Rainer Riedl wrote:
> > I second what Axel has said, real constants (i.e. not #defines) should 
> > be written with a k, followed by the name in mixed case.
> 
> Hmm, ok, but we talk about defines here :-)

Err, indeed we do (stupid me). After looking at the code fragments, I 
suppose that ideally, we should rename *all* of constants, as even the ones 
that start with a 'k' only do so because that 'k' is meant to be an 
abbreviation for 'key' (as kmsg_... represents a keyboard message).
In order to avoid this rather large amount of work, I believe we should 
restrict ourselves to giving those constants consistent names, i.e. 
capitalized ones.

Furthermore, I suppose it would be neat to replace those #defines with 
anonymous enums, i.e. replace

        #define msg_New                                                 'New '
        #define msg_Open                                                'Open'
        #define msg_FtpOpen                                             'FtOp'
        #define msg_BtnOpen                                             'BOpn'
        .
        .
        .

with 

        enum {
                msg_New                 =       'New ',
                msg_Open                =       'Open',
                msg_FtpOpen             =   'FtOp',
                msg_BtnOpen             =   'BOpn',
                .
                .
                .
    };

What do you think?

cheers,
        Oliver

Other related posts: