This document is copyrighted by Shlomi Fish under the Creative Commons Attribution 4.0 Unported License.
Code excerpts are assumed to be under the https://en.wikipedia.org/wiki/MIT_License .
Copyright © 2010 Shlomi Fish
This document is copyrighted by Shlomi Fish under the Creative Commons Attribution 4.0 Unported License.
Code excerpts are assumed to be under the https://en.wikipedia.org/wiki/MIT_License .
Often when people ask for help with C or C++ code, they show code that suffers from many bad or outdated elements. This is expected, as there are many bad tutorials out there, and lots of bad code that people have learned from, but it is still not desirable. To encourage best practices, here is a document of some of the common bad elements that people tend to use and some better practices that should be used instead.
A book I read said, that as opposed to most previous idea systems, they were trying to liquidate negatives instead of to instil positives in people. So in the spirit of liquidating negatives, this tutorial-in-reverse aims to show you what not to do.
Note: Please don't think this advice is meant as gospel. There are some instances where one can expect to deviate from it, and a lot of it can be considered only the opinion of its originators. I tried to filter the various pieces of advice I found in the sources and get rid of things that are either a matter of taste, or not so critical, or that have arguments for and against (so-called colour of the bike shed arguments), but some of the advice here may still be controversial.