Style guides for Google-originated open-source projects
code.google.com/p/google-styleguide/Posted Feb 17, 2009, 6:04 AM UTC
Posted Feb 17, 2009, 6:04 AM UTC
[deleted]
Hmmm.
class PuppyDog
variable puppy_dog
constant kPuppyDog
function ChewBone()
setter set_weight()
getter weight()
private var weight_
macro BARK_LOUDLY
The different styles of function naming irk me. I can see where this scheme has value when consistently applied.
But:
... eschew abbreviation ... So, no "HTTP" or "SMTP" in your code? Or is there a threshold here?
class ParallelHypertextTransferProtocolClient {
No, they mean something like ParallelHttpClient. Way more readable than ParallelHTTPClient, and you still know what's going on. You can probably assume (though I've been proven wrong on so many assumptions about programmers) that any sufficiently technical person knows what "http" means, regardless of capitalization :)
You're right. From http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#General_Naming_Rules:
int num_dns_connections; // Most people know what "DNS" stands for.
But then I noticed:
Never abbreviate by leaving out letters: int error_cnt; // Bad.
Isn't "num" an abbreviation for "number", formed by leaving out letters?
I don't like capitalized function names. Remind me Microsoft style. Capitalized identifiers are types (classes or other).
For me: ClassName, functionName(), variableName, CONSTANT_NAME (from enum or const or define), _privateMember (if colliding with accessor).
ClassName, function_name, variable_name, CONSTANT_NAME, _private_usually_not_like_that.
Both of you need to STOP IT ALREADY with the leading underscores. It's in the goddamned standard.
You may notice that the rule only applies to names at global scope, but overriding in a local scope could break a poorly-written macro. Use an m or a trailing underscore.
an Emacs settings file for Google style.
but nothing for vim :-(
I find it most interesting that there's no Javascript, Java, or Python styleguide in the lot (just C, C++, and Obj-C).
Yet public.
Google maintains a internal database of developers which have earned "readability" approval on a per-language basis. There are strict style guides for all supported languages at Google.
Perhaps this Google Python style guide might help with figuring out how Google's looks like.
Quoted from one of Todd Larsen's comments: