[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Some issues with the codebase
From: |
Chad Yates |
Subject: |
RE: Some issues with the codebase |
Date: |
Thu, 09 Jan 2003 15:26:45 -0800 |
> >I also like the "java" style with infix caps except the first word (ie.
> >getMyProperty, setMyProperty, doSomething, isActive...) and then classes
> >using plain infix caps (i.e. Digest, Thread, CRCDigest...) for the most
> >
> but then how do you differ between class and instance.
this is an interesting point. in the past I typically have used the naming
convention for methods. first letter lowercase, infix afterwards. but
sometimes underscores.
TCPSession clientSession;
or:
TCPSession client_session;
or (if compactness is key to it's readability and the number of local
variables are limited), something like:
TCPSession clnt_ses;
or some other type.
Whichever way, I try and specialize the name away from the general class
name, afterall an instance isn't a general class, it's a very specific
object built using the class as a "guide" Car -> playerVehicle/playerCar for
a game, or vector<Car> favoriteCars. :) It's really not as important since
it's not a part of the "public" api. My opinion/style anyway.
> >part the areas I have used in common c++ seem to already be using that
> >style, except for a there are some places that use
> 'doSomething', and others
> >that use 'DoSomething'. It would be nice to come up with a
> style guide for
> >all new code, and then slowly move the existing code that is out of spec
> >into spec deprecating the old method names, and at some point
> (say a major
> >release) removing them.
> >
> >
> In my opinion there should be a clear difference in between type,
> instance, constant, method (do,get,set), local or privat member member,
> global variable. Did I miss something?
After writing this and then checking out the latest patches/changes, I
discovered there is a Code style written up, it's in the texi documentation
(I still haven't figured out how to view).
If you want to know what I typically use:
1) Types: named like classes since they are in the same family and
represent an object/primitive of some sort.
2) Instances/Attributes/Variables: named like methods but more lax.
3) Constants: all UPPERCASE, PI, MAX_SIZE, enum {RED, GREEN, BLUE}
4) Methods: as above, typcially verb prefix + (processJob, addElement..)
5) Private: in the private section of the class declaration. no
distinction from other member variables (hey they may start public,
but then be moved to private or vice versa.
6) Global: ?? I don't use these except under extreme conditions. but I
would expect same as Methods and Member variables
> why not simple using comm ?? placeholder for common c++ or
> communication :-)
>
> I think this is a very esotheric issue and so many different opinions
> around ... so sorry for bugging you ;-)
It's really a can of worms isn't it. or maybe snakes. :)
Later!
chad