Google C++ Style Guide
-
Some nice reading on the "style" of C++ code at Google open source projects: The "Google C++ Style Guide":http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml
It has some good technical explanations for various style rules. Others are clearly more a matter of taste type of rules, and are arguable - as always in this sujet :-)
Nontheless, enjoy reading!
-
I did not compare them thoroughly, but I would say they differ in naming conventions and they do more strictly enforce the rules at all (against Qt which says: follow the rules wherever you can, but feel free to break them here and then where it makes sense).
-
Good reading, but some points I'd rather to change...
As I am reading more, I am glad to we have Qt "style"...
-
I think the Google style guide documents the exact mistake a lot of companies make when they are prescribing the style this specifically. Programmers are usually free form thinkers. Putting a too rigid harness on that free form thinking lets developers focus on form rather than on functionality, and frankly, I'd rather have a bit of functionality. If you want to restrict coding rigidly to a certain standard, use a language that isn't as free form as C++.
-
Volker, thanks for sharing! It is always good to know how leading companies work.
[quote author="Andre" date="1305548881"]Personally, I really like the Qt convention that class names start with a capital, and method names with a lower case letter. That is different in the Google conventions. [/quote]
Yes it is really nice, although I have to admit that I am still getting used to it :)
[quote author="Franzk" date="1305574936"]I think the Google style guide documents the exact mistake a lot of companies make when they are prescribing the style this specifically. Programmers are usually free form thinkers. Putting a too rigid harness on that free form thinking lets developers focus on form rather than on functionality, and frankly, I'd rather have a bit of functionality. If you want to restrict coding rigidly to a certain standard, use a language that isn't as free form as C++.[/quote]
+1 :) Bull's eye! :)
-
I prefer Unix or BSD style, it's not so strict as Google has...
Joke:
But the best thing that they wrote, was: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=C++0x#C++0x
" Decision: Use only C++0x libraries and language features that have been approved for use. Currently, no such features are approved. Features will be approved individually as appropriate."
How can I use C++0x (as it Google said), if there is just specification out?? Think smarter and you'll get nonsense of using this Google Style :D -
I wonder, do trolls have analog cpplint.py?:)
-
http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Inline_Functions
Does Qt encourage inline functions inside the library which can be called from user code ? I guess it could cause binary incompatibilities if definition of inline function changes between library versions.
-
Inline functions are not strongly en- ord discouraged, but the "Coding Conventions":http://developer.qt.nokia.com/wiki/Coding_Conventions section "Binary and Source Compatibility":http://developer.qt.nokia.com/wiki/Coding_Conventions#017d38d16f3e68ae84e92996ba58c513 requires not to reimplement them (dunno if a change to the code itself would be ok) under certain circumstances.
Inline functions an B/C are a special beast, which would lead to use this feature only for short code blocks that are unlikely to change. I second the guidelines of Google here (excluding the -inl.h files).
EDIT:
To add the Qt counterparts for comparison:- "Qt Coding Conventions":http://developer.qt.nokia.com/wiki/Coding_Conventions
- "Qt Coding Style":http://developer.qt.nokia.com/wiki/Qt_Coding_Style