Res. on WHY bad coding is bad

Started by
3 comments, last by Treb 15 years, 4 months ago
I'm looking for a resource that explains why bad C++ coding is bad and optionally why good coding is good. Nothing exotic, just the ones that are obvious to some of us because we've experienced directly, but not-so-obvious to others of us because we haven't experienced it directly. You know... use std::string instead of char* or char[256] because it handles arbitrary length issues, null pointers aren't an issue and don't have to be checked for every time you use the string, array bounds don't have to be checked because they are handled internally with a reallocation instead of having to cut the string off at a certain point, etc. Or... don't make that array instantiation in your class public, even though right now you only use it in one place. Oh, you can just copy and paste your code that uses the array from here to there? No... don't do that either... because [...] And so on. Anyone know of anything online like that? I'm sure its out there I just can't track anything really useful down at the moment right now... I keep finding things that tell you what to do or what not to do... but not necessarily why. Cheers -Scott
Advertisement
C++ is such a wide topic that it'd be hard for any one resource to explain all bad practices, but there are a few places you could start:

The C++ FAQ lite is probably the best all-round resource for a beginning or intermediate programmer.

Meyers' Effective C++ books explain many common bits of wisdom very well.

Sutter and Alexandrescu's C++ Coding Standards is proabably the best all-rounder for a slightly more experienced programmer.
[size="1"]
Code Complete is a classic text that speaks more generally about coding, sometimes language specific but often not. Most of the C++ issues you face are specific instances of general problems that exist across many languages, arising from the mismatch between what humans want to achieve and the way computers force us to attempt them. So a more general book like Code Complete can tell you a lot.
Effective C++ is directly on point, and Code Complete is a good resource too (though perhaps more directly related to procedure and development practices).

Or y'know, hang around forums. By the time I got to Effective C++ most of the tidbits had already been covered here.
also visit http://www.gotw.ca/gotw/ most of the topics are advanced, but it's a fantastic free resource.

This topic is closed to new replies.

Advertisement