Naming Conventions
 

 



next up previous contents
Next: An Example Package Up: No Title Previous: Packages and File

Naming Conventions

 

This chapter discusses the conventions for naming functions, macros, structures, and variables within the VIS environment. The objective of these conventions is for a name to be canonical and to completely identify its type and scope. Adhering to these conventions is necessary for the automatic prototype generation and documentation tools to work, described in Chapter 5.

When names are longer than one English word, the words are catenated and their first letters capitalized, e.g., ThisIsALongExample. This is shorter than other styles, and is at least as readable.

The environment defines three scopes, each of which has its own naming convention:

  • External: features visible outside the package. Names are prefixed with ``package_''.
  • Internal: features not visible outside, but visible throughout the package. Names are prefixed with ``package''.
  • Local: features visible only within a single file or function. Names have no package prefix.

Functions and macros, variables, and structures each have their own naming convention:

  • Functions/Macros: The package name and the first word of the rest of the name are both capitalized.

    The words in a function name are arranged in an English sentence-like order:

    1. First word: Name of the object being operated on: the subject of the sentence (e.g., Range, Network).

    2. Second word: The action being performed on the object: the verb of the sentence (e.g., Read, Obtain, Alloc). Obtain is used for functions that return a pointer to a copy of a data structure that must later be freed by the caller. Read is used for all other cases. Get should not be used.

    3. Third and successive words: Modifiers: the object of the sentence (e.g., States, RightChild, BddIdArrayFromMddId).

  • Variables: The package name is lowercase. The first word of the rest of name is lowercase except for internal variables.

  • Structures: Type definitions for these have the package name and the first word is capitalized, and the name has a _t suffix.

  • Constants: All letters are capitalized; all words are separated by underlines (``_'').

  • Enumerations: Type definitions for these have the package name and the first word capitalized, and the name as a _c suffix.

The table below gives examples of names.



next up previous contents
Next: An Example Package Up: No Title Previous: Packages and File



Tom Shiple
Fri May 10 17:19:47 PDT 1996
Contact 
©2002-2018 U.C. Regents