The code examples in The Practice of Programming are atrocious, and I mean it - they are full of really, really bad naming and arcane abbreviations and thus unreadable code.
How is this for readable and maintainable code? (Random code example from The Practice of Programming, copied verbatim letter by letter)
/* delname: remove first matching nameval from nvtab */
int delname(char *name)
{
int i;
for (i = 0; i < nvtab.nval; i++)
if (strcmp(nvtab.nameval[i].name, name) == 0) {
memmove(nvtab.nameval+i, nvtab.nameval+i+1),
(nvtab.nval-(i+1)) * sizeof(Nameval);
nvtab.nval--;
return 1;
}
return 0;
}
- Confusing function explanation in a custom format. What is nameval? What is nvtab?- Missing curly braces in the for loop
- Confusing long lines (line starting with memmove())
- Confusing inline transformations: nvtab.nameval+i+1, nvtab.nval-(i+1) directly in function arguments. What do they mean?
- Bad, bad naming (nvtab, nameval)
- Inconsistent case (nameval vs Nameval)
This is just ONE RANDOM EXAMPLE, mind you. The book is atrocious, I don't recommend it to anyone.
Code Complete is much thicker but that's the only disadvantage. It's not bloated, it's simply more comprehensive, it's consistent and teaches to write actual readable code.