The collection of terrible tips for C++ developers

It could be tedious to constantly explain "how to do proper coding". So, I wrote a small book called "60 terrible tips for a C++ developer" - https://pvs-studio.com/en/blog/posts/cpp/1053/

The book not only provides terrible tips, but also explains why a tip is terrible.
It could be helpful for newbies in programming. You might meet someone who follows some of the tips mentioned in this book. You should definitely show it to them :). Experienced developers will find it valuable too. The book can help them refresh their knowledge and deepen the understanding of C++ subtleties.

A word of warning: there's a lot of text. Please grab a coffee/energy drink and enjoy reading. I would welcome any discussions or feedback.

Here are a few terrible tips from the book:
• Use invisible characters in your code. Let your code work like magic. That's cool.
• Show a little respect for programmers of the past — declare all variables at the beginning of functions. It's a tradition!
• Write your .h-files so that they depend on other headers, and do not include them in your header file. Let the one who use include guess what header files need to be included in advance before using your file. Entertain your colleagues with quests!
• Write your code as if the chairman of the IOCCC judges will read it and as if they know where you live (to come and give you the prize).
• Write comments to explain what exactly a line of code does. Yet every true coder understands why this is done.

It's a fun and serious piece at the same time. No matter how terrible these tips look, they aren't fiction, they are real: we saw them all in the real programming world.
One of my favourites is to mix signed and unsigned in an expression. Provides hours of fun!
I honestly think nowadays PCHs aren't really worth it. With modern highly parallel processors it doesn't make as much sense to complicate the build system more than absolutely necessary. Unless you have some really huge header that needs to be included in lots of places (e.g. something like Boost.Spirit, which is legendary), the PCH is just an unparallelizable task which every translation unit needs to wait on, even when they don't use all of those headers.
Topic archived. No new replies allowed.