Sign in to follow this  
popsoftheyear

Res. on WHY bad coding is bad

Recommended Posts

popsoftheyear    2194
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

Share this post


Link to post
Share on other sites
mrbastard    1577
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.

Share this post


Link to post
Share on other sites
Kylotan    9977
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.

Share this post


Link to post
Share on other sites
Telastyn    3777
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this