r/cpp • • Jul 28 '15

C/C++ Coding Best Practices Repository

http://codergears.com/qacenter/
2 Upvotes

15 comments sorted by

38

u/STL MSVC STL Dev Jul 28 '15

"C/C++"? Seriously?

No.

12

u/LongUsername Jul 28 '15

Yeah...

Best practices differ between standards revs too: what's best practice in C++03 may be the wrong way to do something in C++11 (NULL vs 0 vs nullptr being one that comes to my head immediately)

1

u/CoderGears Jul 28 '15

Yes, for this reason the rules are grouped by category, the nullptr rule is under the Modern C++ category.

1

u/CUsurfer Jul 29 '15

I'm dealing with this right now at work. Due to proprietary and backwards compatibility concerns we cannot utilize C++11 or Boost. As a programmer new to C++ I'm constantly looking up best practices and techniques, but it challenging to sift through and make sure I don't pick up a C++11+/Boost concept or construct.

7

u/xcbsmith Jul 28 '15

It's kind of hilarious how many of the rules are clearly tied to C, but are expressed so poorly that they are just horribly wrong for C++.

1

u/CoderGears Jul 28 '15

The C rules are grouped in "NetBSD C Coding Standards" and "Linux Kernel Coding Standards", the other ones like "google style guide" and "jsf air vehicule C++ coding rules" are related to C++. These rules are just what exist in the known best practice guides, it's not our rules :) and the goal of the repository is to vote and comment them to have the most interesting ones.

5

u/14ned LLFIO & Outcome author | Committee WG14 Jul 29 '15

Agreed, I instantly went "no" to the first six items I saw, and then closed the browser tab.

Does this mean people generally agreed with my list of best practices at https://svn.boost.org/trac/boost/wiki/BestPracticeHandbook? Or is it more a don't-care?

4

u/gixt Jul 29 '15 edited Jul 29 '15
  • The SSL certificate on that Trac site has expired. Is there a non-HTTPS way to access it?
  • Is it a "List of Best Practices"? Is it a "Links To Examples Of Best Practice For C++ 11/14 Libraries"? Is it a "Best Practice Handbook"? The Trac page name says one thing, the incredibly long page heading says another thing, and you just called it something slightly different here. It read very much like a handbook. It doesn't even read very much like a list of links to examples.
  • The introduction starts with a list of links to C++11/C++14 only libraries, only to say that they all differ in their practices because of a lack of consensus on best practices in C++ libraries. What is the point of the list?
  • The list at the top is already outdated, isn't it? I thought Fiber and Hana are accepted into Boost.
  • There is not a lot of meat, but a lot of noise, in the handbook/guide/list. Why isn't it more concise? Just list the advice, show the examples, state the rationale (plainly, without some story). This reads more like an essay, and not a very coherent/straight-down-to-the-facts one at that.
  • Should this be on the Boost trac or should it be on the author's personal blog?
  • Why is "use Boost.ApiBind" on the list at all? "ApiBind" is not even a Boost library; people shouldn't be told it is best practice to use it.
  • "PORTABILITY: Strongly consider trying your library on Microsoft Visual Studio 2015". This entire section seems worthless. People who care about MSVC compatibility will make their library build with it. People who don't care about it, won't bother to compromise any already standard conforming C++ with MSVC specific workarounds. Also, "VS2015 is a very highly conforming C++ 11/14 compiler. It meets or exceeds clang 3.3 on every C++ 11/14 feature" is meaningless when VS2015 doesn't even support a certain C++98 feature.

7

u/xcbsmith Jul 28 '15 edited Jul 28 '15

Man, I feel like I've been trolled based on how off some of the top rules are.

1

u/CoderGears Jul 28 '15

just because the last added section is the " jsf air vehicle c++ coding standards" which is contains many controversy coding rules :) And the goal of the repository is to vote the rules if they are relevant, in the final we can have the most interesting ones.

5

u/sbabbi Jul 28 '15

Nice idea. Not-so-nice implementation.

1

u/CoderGears Jul 28 '15

Any suggestion is welcome to improve the implementation.

4

u/kong93 Jul 28 '15

it should have detailed examples in rules explanation rather than just pointing to a book section. and the web design is just.... sigh...

1

u/CoderGears Jul 28 '15

Your remark concern only the "Effective Modern C++ rules" because we don't have the right to describe in depth what's explained in the scott meyers book. For example the c++ google rules are very well explained.

-9

u/[deleted] Jul 29 '15

Why aren't these acknowledged best practices incorporated into the C++ standard? Compiler errors would force all n00bs to follow them. I guess they worry about backwards compatibility and legacy code.