Chapter 3: What’s in a Name?
Mull It Over
Are these good variable names? Answer with either yes (explain why, and in what context), no (explain why), or can’t tell (explain why).
int apple_countchar foobool apple_countchar *stringint loop_counter
The quality of a name depends on its context, and we can’t honestly tell
whether any of these are good or bad names. That’s why the question asks for
example contexts. There are some obvious contexts where the names might be
bad: apple_count wouldn’t be a
particularly good name for a grapefruit counter.
foo is never a
good name. I’ve yet to see anyone counting foos.
loop_counter is also bad; even if a loop gets too big for a short counter name, you can still pick a more descriptive name, one that reflects ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access