Defining Programming Standards   
for Professional Programmers 
  

         

Home

Contents

1: Standards

2: Psychological Factors

3: General Principles

4: Commenting

5: Naming

6: Code Layout

7: File Layout

8: Language Usage

9: Data Usage

10: Programming Usage

11: Implementing Standards

A: Example Standard

B: References

C: Glossary

Syque

About

Share this page:

Google
C Style
syque.com
Web

 

 

Books and
more at:

USA:

In association with amazon.com

UK:

In Association with Amazon.co.uk

Canada:

In Association with amazon.ca

 

 

CHAPTER 5 : Naming

PART 2 : COMMENTING AND NAMING

CHAPTER 5 : Naming
5.1 Constraints upon naming
5.2 Abbreviations
5.3 Short names
5.4 Separating words
5.5 Spelling of names
5.6 Naming functions
5.7 Indicating functional group
5.8 Naming variables
5.9 Indicating type
5.10 Naming replacement items
5.11 Naming Files and Directories
5.12 Summary

<--Prev page | Next page -->

 

5.2  Abbreviations

Abbreviations are useful for reducing the length of a name, making it more manageable (and sometimes more readable too!). Thus:

 

ParagraphStatus    ..becomes..    ParaSts

 

The danger with abbreviations is that they are often over-used, and names become unintelligible. The author is so accustomed to using his own abbreviation standards and methods, that 'FstPghLnSz' clearly means 'First paragraph line size' to him. Too many abbreviations put together like this are clearly unclear.

Abbreviations are often clear within context, but are unclear when viewed on their own. Does 'Wgt' mean 'Widget', or 'Weight', or something else?

A good test of an abbreviation: can it be pronounced? A really good abbreviation significantly reduces the number of letters used and can be understood both when looked at and when spoken:

 

Char, Curs, Len

 

There are several strategies for generating abbreviations:

  1. Use the beginning of the word, e.g.  Char, Para, Buf
  2. Remove the vowels from the word, e.g.  Chrctr, Prgrph, Bffr
  3. Retain the major sounds of the word (use the sounds of letters), e.g.  Crctr, Pgph, Bufr
  4. Select critical letters of the word, e.g.  Chr, Pgh, Bfr
  5. Use well-established abbreviations, e.g.  c, Para, Buf

Once an abbreviation is used, then it is important that the same spelling is used consistently. If a different spelling for the same abbreviation is used, then it can easily cause confusion. eg. 'WinHgt' uses 'Win' as an abbreviation for 'Window' and 'Hgt' as an abbreviation for 'Height'. It would be confusing to subsequently use names like 'WndwWidth' or 'CharHght'.

 

<--Prev page | Next page -->

 

 

  © Syque 1995-2006

Massive Content -- Maximum Speed