Saturday, February 21, 2009

What's In A Name?

One of the big issues for code clarity is determining the intent of a function from its name.  One of the tricks that I've taken to doing is to name the function such that when I read the code out loud, it sounds like I'm speaking normally, or nearly so.

For example, if I'm testing a file for various criteria, I'll have this:

if(fileIsRightSize() && fileIsNotWritable())
{
         saveFile()
}

The cognitive benefit from this is immense.  It's not a new idea, but I'm not seeing it get traction in code today.


Technorati Tags --
, , ,
HTTP

No comments: