Worst practices in C++, common mistakes ...
Posted
by
Felix Dombek
on Programmers
See other posts from Programmers
or by Felix Dombek
Published on 2011-02-07T20:09:19Z
Indexed on
2011/02/07
23:34 UTC
Read the original article
Hit count: 313
After reading this famous rant by Linus Torvalds, I wondered what actually are all the bad things programmers might do in C++. I'm explicitly not referring to typography errors or bad program flow as treated in this question and answers, but to more high-level errors which are not detected by the compiler and do not result in obvious bugs at first run, complete design errors, things which are improbable in C but are likely to be done by newcomers who don't understand the full implications of their code.
I also welcome answers pointing out a huge performance decrease where it would not usually be expected. An example of what one of my professors once told me:
You have used somewhat too many instances of unneeded inheritance and virtuality. Inheritance makes a design much more complicated (and inefficient because of the RTTI (run-time type inference) subsystem), and it should therefore only be used where it makes sense, e.g. for the actions in the parse table." [I wrote an LR(1) parser generator.] "Because you make intensive use of templates, you practically don't need inheritance."
© Programmers or respective owner