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

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

 

 

  © Syque 1995-2013

Massive Content -- Maximum Speed