PBP: 023 Identifiers

This section of the PBP is a long one, and goes into great detail about how to think about naming important parts of your programs.  It covers explicitly modules/namespaces, variables (several types of them), and functions.

I thought, at first glance, it was way too picky and specific, but the more I read it, the more I liked it.

I also discovered that it’s what the cleanest code I’ve worked with does already, either deliberately or through evolution.

The naming for namespaces is described as Noun::Adjective::Adjective…, and that seems reasonable.  I know at work we put an extra thing in front, to put it firmly in the company namespace, then follow those rules.  It makes all our specific stuff start with the work namespace, which can be redundant, but makes it blindingly clear what parts are internal and private, and what parts are general and could be shared.

Naming for functions is also well thought, and goes into quite some detail.  I’m not sure I would have expressed all the detail, but we should all remember that Mr. Conway has also contributed to the Lingua::EN namespace, and understands these issues well.  In this case, I think it served well as he could be clear and correct.

Variable names are also discussed in some detail, with good results.

I admit, I often use short items for nearby, local things, or things that will appear a lot.  I still use loop variables with one letter, especially when they only exist inside a five line long for loop. They are not as clear as they could be, but they try and keep the comprehensibility of the block as a whole high by not requiring more understanding.  That’s probably where I fail the most in these habits.


Leave a Reply