What makes code crappy?

When it comes to maintaining code, I believe there are 2 kinds of crap: subjective (I don’t like it) and objective (it’s crap because of these 14 specific reasons). 

You’re probably right about people who inherit my code. I know, when they’ve whined about it, I confronted them. “Please show me exactly what’s wrong with it. What are your specific complaints about violations?” I rarely got an objective answer. It was usually something about formatting, indenting, variable names too long, variable names too short, I’m used to it the way we did it (wrongly) at XYZ Co., something like that. 

True crap can be objectively identified by a violation such as: 


- variables named so that no one except King Tut could possibly figure out what they are 

- the same variables used for different purpose “at the same time”, usually in nested recursions 

- variables named with 1 or 2 characters 

- unassigned variables 

- variables initiated when they shouldn’t be 

- division by zero 

- single entry, multiple exit (heavily maintained so that now outlying cases skip critical logic) 

- the same code in multiple places (only some of it maintained so that outlying cases skip critical logic) 

- endless recursions (for outlying cases only, naturally) 

- comments that don’t agree with the code 

- data base tables with no definitions either in the schema or any code (my new favorite) 


I could go on and on, but you kinda get the picture. I wonder how many readers here have posted crap like this on their “wall of shame” at one time or another. It’s funny the first 2^n times. Not so much fun anymore.