For example, use names like
CorporateCustomer. Although names like
fn are easy to type because they're short, they do not provide any indication of what they represent and result in code that is difficult to understand, maintain, and enhance.
If your users refer to their clients as customers, then use the term
Customer for the class, not
Client. Many developers make the mistake of creating generic terms for concepts when perfectly good terms already exist in the industry or domain.
You should use lowercase letters in general, but capitalize the first letter of class names and interface names, as well as the first letter of any non-initial word.
This means you should maintain a list of standard short forms (abbreviations), you should choose them wisely, and you should use them consistently. For example, if you want to use a short form for the word number, then choose one of
num, document the one you choose (it doesn't really matter which one), and use only that one.
Although the class name
PhysicalOrVirtualProductOrService might seem to be a good class name at the time (OK, I'm stretching it on this example), this name is simply too long and you should consider renaming it to something shorter -- perhaps something like
The variable names
should not be used together, nor should
Names will often contain standard abbreviations, such as SQL for Standard Query Language. Names such as
sqlDatabase for an attribute or
SqlDatabase for a class are easier to read than
- Building Object Applications That Work: Your Step-By-Step Handbook for Developing Robust Systems with Object Technology by Scott W. Ambler
- The Object Primer 2nd Edition by Scott W. Ambler
- The Elements of Java Style by Alan Vermeulen, Scott W. Ambler, Greg Bumgardner, Eldon Metz, Trevor Misfeldt, Jim Shur, and Patrick Thompson
Scott W. Ambler is President of Ronin International, a consulting firm specializing in object-oriented software process mentoring, architectural modeling, and Enterprise JavaBeans (EJB) development. He has authored or co-authored several books about object-oriented development, including the recently released The Object Primer 2nd Edition, which covers, in detail, the subjects summarized in this article. He can be reached at email@example.com and at his Web site at www.ambysoft.com.