syque.com

The Psychology of Quality and More

| Menu | Books | Share | Search | Settings |

C Style: Standards and Guidelines (contents)

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 -->

<-- Prev Chapter | Next Chapter -->

 

One of the most difficult and yet one of the most common tasks a programmer has to do is to find suitable names for all of the 'int's, 'char's, etc. in his program. It is often too easy to underestimate this task, and identifiers that convey little or insufficient meaning are remarkably common:

 

a, b, buf, temp, temp1, first, count, ptr

 

Books, articles and lectures on C often use such names not so much because of a lack of style, but more because they are illustrating a point of language, and the code fragments they use are sufficiently small that the limited meaning of these names does not matter.

So how do you make a name meaningful? The best approach must be to describe what the named item does, what it is for, etc. When read, it should sound natural, and should help the reader understand its purpose without having to read the rest of the code ("Ah, so that's what it's for!").

This chapter looks at some methods for creating names, and their applications and limitations when used for identifiers in C.

 

<--Prev page | Next page -->

 

Site Menu

| Home | Top | Settings |

Quality: | Quality Toolbook | Tools of the Trade | Improvement Encyclopedia | Quality Articles | Being Creative | Being Persuasive |

And: | C Style (Book) | Stories | Articles | Bookstore | My Photos | About | Contact |

Settings: | Computer layout | Mobile layout | Small font | Medium font | Large font | Translate |

 

You can buy books here

More Kindle books:

And the big
paperback book


Look inside

 

Please help and share:

 

| Home | Top | Menu |

© Changing Works 2002-
Massive Content -- Maximum Speed