Saturday, February 9, 2013

Odometer-style Naming


Naming things is most important when writing code. Variable names and function names can make a lot of comments unnecessary. This shortens the code and creates less distraction. Reading code with good naming is like reading an outline of the work done by the program code. The code should be like an outline.

I automatically carry over my programming skills to my work with AutoCAD. Good naming for drawings and for blocks in drawings makes it easier to find the files I'm looking for. Let me give you an example.

The job I'm working on might have three main parts: Parts A, B, and C. (At my job, we actually use single letters to identify the main parts of a job. If you don't, you might want to look for maybe a three-letter abbreviation for each major part.)

Part A of the job might have Assembly Type 1, Type 2, and Type 3.

Part A Type 2 might have a Right-hand and a Left-hand sub-assembly. I would name these A2R and A2L.

The other guy at work might name them AR2 and AL2. (In the old days, he would have had long, wordy names for them. He has since taken to modeling his filenames after mine. But he doesn't get the nuance that this post describes.)

My naming works like an odometer: The rightmost character changes most often, and the changes are fewer as you step to the left. This is not by accident. It makes the file system automatically put things in order for me. I don't want all the "Rights" for Part A to be listed together. I want all the Type 2 of Part A to be listed together. That's what my naming gives me.

Maybe -- sure, maybe it works because I have adapted my way of thinking to take advantage of the way the computer works. But that's exactly what you want to do, to be good at this stuff.

And the naming rules that evolved during my many years of learning to program, those same rules work very well for my work with AutoCAD.

No comments: