Dave's Brain

Browse - Programming Tips - Do names of things matter?

Date: 2016may16

Q.  Do names of things matter?

A.  Yes.  A lot.
If you can make good names of variables, function, modules your
program will nearly write itself.  This also includes names of command-line 
options and files your programs use.

Obviously follow the naming contentions of your language or environment.
eg in C/C++ MACROS and CONSTANTS are uppercase.  Other things aren't.
in Java, Classes are title case.  variables start with lowercase.

Be as specific as possible without being over specific.
ProcessFile() is bad since it doesn't say what's going on.
ReadBytesAndCountThem() is over specific.
CountBytes(filename) is just right.

Be consistent.  Don't have a function called CountBytes()
and another called CharacterCount()

If you notice that a name of a function (or something) no longer describes
what it does, you should change it.  Even if its a big of trouble.
Of course, APIs are an exception.

Here's an article about naming variables.
http://www.makinggoodsoftware.com/2009/05/04/71-tips-for-naming-variables/

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.