You are not logged in.
Did I miss the boat? This seems counterintuitive to me. Maybe it's a Windows-centric thing?
http://google-styleguide.googlecode.com … tion_Names
http://msdn.microsoft.com/en-us/library … 71%29.aspx
Offline
It's strange. When I write in C, I keep all functions lowercase. However, when I write in Python, I keep it capitalized, such as OpenWindow(), CloseWindow(), etc.
Offline
I tend to just go with whatever looks better in a given situation.
But, then again, I use 2 spaces for indenting in python. *hides*
Offline
It's a matter of personal taste.
First and for most I will keep the same style as whatever project I'm working on.
If it's my own project I usually google up what the common idiom is for each language.
<insert hardware wankery>
Offline
Like otterfox I tend to stay with whatever style was used on the project before if I join an existing project.
Personally I like to start function names with a lower case letter.
I haven't lost my mind; I have a tape back-up somewhere.
Twitter
Offline
for me:
function = lowercase
Object = uppercase
Offline
My C projects tend to use all lowercase. I have some weird stigma about seeing uppercase (usually camelCase) in C.
Tangent: Go uses capitalization to determine visibility. This is true of both functions and variables.
foo = private
pkg.Foobaz() = public
Offline
Did I miss the boat? This seems counterintuitive to me. Maybe it's a Windows-centric thing?
From the small amount of time I've spent studying and using the Windows API, yes, the Windows API has functions that are spelled with camel-case with the first letter capitalized. That's the only place I've seen that in C++.
I'm a little surprised to see it on the Google page that you posted, but maybe not too surprised. It says functions and Classes AreLikeThis() and methods are_like_this(). Seeing how both functions and classes are used "at a higher level" than method names, I could understand why it would be done that way. Now that I think about it, I don't think I've personally decided yet which I would pick if I wrote a function along with some object oriented code.
And yes. it seems counterintuitive to me too.
Offline
There's nothing inherently intuitive about having the first letter be lower-case - it's just what you're used to. It's no surprise C/C++ programmers are more used to lower-case; their standard libraries don't use capitals at all, but rather completely lower-case with underscores (std::for_each, std::multiset::lower_bound, etc...) - other languages will have different styles in their standard libraries. Heck, at work, we use C++, and I've seen method names that run the gamut (GetSize, setSize, calculate_volume, etc...)
I frankly don't see the big deal - everybody's got a programming style, and those styles will differ. There's no boat to miss, really. If you've been lower-casing your method names, then all the power to you. Just try to keep it consistent.
Offline
It is slightly more intuitive to a German programmer as in Germany nouns have their first letter upper case anyway. So if you think of class/function names as nouns this comes more natural.
So this naming convention was inspired by a German rule? At least it is somewhat natural to me.
But nevertheless, I'll always stick to the convention a given project uses.
Last edited by bernarcher (2010-08-05 12:18:46)
To know or not to know ...
... the questions remain forever.
Offline
It's strange. When I write in C, I keep all functions lowercase. However, when I write in Python, I keep it capitalized, such as OpenWindow(), CloseWindow(), etc.
PEP8 suggests function names should be lower_case_like_this where class names should be UppercaseLikeThis.
Last edited by rson451 (2010-08-05 12:51:32)
archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson
Offline
For me, constants are all caps,
#define MAXSIZE 80
Functions, structs, classes, first letter is lower case, from second word on is upper,
char getNextLetter(void);
Variables and other stuff, lower case...
That's how I like it, I am sure some people would hate it.
Offline
I started with Java, so of course methods (or functions, whatever they are called in java) areLikeThis(), classes StartWithACapital.
I do prefer the python style for methods - like_this_with_underscores. My preference comes also from the fact that I find typing "_" easier than pressing shift for capital letters (I don't like pressing shifts with my pinkie). (It's a german keyboard, dunno how the english ones are.)
Then I did some C# and raged at the StartMethodsWithCapitals().
There are two types of people in this world - those who can count to 10 by using their fingers, and those who can count to 1023.
Offline
semi-interesting tidbit: In Haskell, functions aren't even allowed to begin with a capital letter.
..and yeah, I know probably no one cares.
Offline
In my opinion, everything should be lowercase, and words should be separated by underscores. Anything else bugs me.
I don't see why you need to sort things by case. It's not like seeing String x lets me know that String is a class any more than string x.
Offline
I don't see why you need to sort things by case. It's not like seeing String x lets me know that String is a class any more than string x.
That's a good point. And in C and C++, classes and structs are in a different namespace than variables, so "string string" wouldn't even be a problem, right?
As a side not, I'm trying to get better and naming my variables after what they represent and not what they are. For example, something like "String name" instead of "String string".
Offline
Classes and structs in the standard libraries are all in the standard namespace, but ones that you define by yourself are not. "string string" would work, but I wouldn't recommend using it. Calling "string string" would really be "std::string string."
Offline
Isn't it a vim convention to capitalize your own custom function names to distinguish them from the built in ones?
Offline
My university teaches (and enforces in the introductory CS classes) camelCasing, so I guess that's just what I'm used to seeing. It seems easier to read than alllowercase and more compact than hyphen-delimited-function-names.
As for the code you linked, I believe the casing convention used there is for OO languages. A private field or method is camelCased and a public field or method is PascalCased. That way, you can tell the difference at a glance.
Personally, I like that particular convention. Seems easy to read and holds inherent meaning for the identifiers in question.
Offline
Don't argue about syntax, it is like fashion... All have their style.
"The flesh knows it suffers even when the mind has forgotten."
Offline
Don't argue about syntax, it is like fashion... All have their style.
Yeah, I always use camel, e.g. myFunction(), and that isn't gonna change.
Last edited by GraveyardPC (2010-08-15 08:08:07)
Offline
Functions: doSomething()
Constants: SOMETHING
Objects: Something
Variables: something
I use this scheme, independent of the language I use.
It is better to keep your mouth shut and be thought a fool than to open it and remove all doubt. (Mark Twain)
Offline
semi-interesting tidbit: In Haskell, functions aren't even allowed to begin with a capital letter.
..and yeah, I know probably no one cares.
I only care because I use Xmonad
Offline
semi-interesting tidbit: In Haskell, functions aren't even allowed to begin with a capital letter.
..and yeah, I know probably no one cares.
All 45 Haskell programmers do care!
Haskell's coding convention makes sense when one is in Haskell. Needless to say, strict language constructs can either be a help or a hindrance, depending on how the coder feels about conformity.
Offline
So I can live happily because I did not miss any rule, too. The way I use in C/C++ is inspired from the conventions of certain projects, like GTK+:
- constants: SQC_COLS_ORDER
- functions/methods: sqc_gl_create()
- types/structs/classes: SqcApp
- objects/variables: *guiPtr.
I use to prefix - but in the same style - all of them except variables (unless global - eg. sqcConfig).
Offline