Re: The start of a C/C++ adventure...
On 7/16/2013 11:28 AM, James Kanze wrote:
On Tuesday, 16 July 2013 09:10:58 UTC+1, Ian Collins wrote:
Jorgen Grahn wrote:
I'm personally more on your coworkers' side. In particular I dislike
encoding type information into names, so:
CAxis* AxisA
Axis* AxisA // useless 'C' prefix (from a non-Microsoft perspective)
It is amusing when someone who likes an IDE with intellisense that can
tell you what a type is still uses that strange (to a non-windows
programmer) style..
It depends. Where I currently work, we use one letter prefixes:
B for basic classes, S for structs (which reveal all of their
data) T for class templates, G for namespaces and A for (machine
generated) archive classes. I was against it at the start, but
in practice, it seems to actually be useful: I'd add I for pure
interfaces and F for functional objects, however.
Any convention is good if you play with it consistently. In real world
applications we tend to use 3rd party components, and those water up any
convention pretty fast. So my take was always to put it in the
unregulated territory.
It also means that class names start with two capital letters,
which allows them to be differentiated from function names.
That is the part I normally get confused. Why would I want the
differentiation? The code should read as a good book. There you don;t
need verbs to get distincted by having two-capital start... ;-)
(I was against starting function names with a capital letter,
since this meant that they couldn't be distinguished from class
names.
The only context I can think where class names and function names would
not be obvious (in application code domain) are really constructor calls.
I didn't write too many templates lately (almost none if we filter out
chunks under 4 lines length), but even there it sounds like no help.
And more importantly, the quite basic tools know if something is type or
a function and applies different coloring. So you can tell them by
having other color without fiddling with the name. (maybe that's why I'm
blind to the approach? ;-)
And distinguishing them from class names was more
important than distinguishing them from variables. But with the
above conventions for classes, etc., there's no real problem.)
Isn't that some vim-related artifact? Can't you set those categories to
different color/font style?
And intellisense doesn't tell you whether a class has all data
members public, or only pure virtual functions and no data.
That's true but why should I ever care?