Naming convention (programming)

Naming conventions are nomenclatures, so that conclusions are drawn on the purpose of the program / database so (voluntary ) agreements of programmers, database developers etc., which introduce a specific system for the allocation of identifiers for objects, variables, and constants based on the name immediately can. Similar conventions are employed in the indentation and the meaningful inserting comments in the source code of programs to increase the readability and comprehensibility.

In general, each programming system has its own naming conventions.

Examples

Hungarian notation

In the Microsoft world, the so-called Hungarian notation is in use which can reasonably be concluded from the beginning of an identifier on its type or its intended use.

Coding of the type in the name

From the programming for integers, floating point numbers, special formats and strings:

  • BytZaehler for a counter variable of type byte ( up to size 255)
  • IntZaehler for a counter variable of type integer ( -32768 to 32767 )
  • LngZaehler for a counter variable of type long ( > 32767),
  • SngQuotient for the floating-point result of a division of the Single type,
  • DblQuotient for the floating-point result of a division of Double
  • CurNetto for currency amounts of type Currency,
  • StrFirstName for alphanumeric strings of type String,

Coding of use on behalf

For objects ( here: relational database):

  • TblKunde for a table (English table ) that contains customer data,
  • QryPLZ4 for a query (English query), the 40000-49999 compiles all customers in the postcode area,
  • FrmAuftrag for a form (English form), included in the customer orders / display / change / can be deleted,
  • RepUms2005 - 12_Knd1010 for a report (English report) in which all of the customer sales are listed with the customer number 1010, which were made ​​in December 2005.

Meanwhile, Microsoft recommends that you dispense with C # on the Hungarian notation.

Constants in C

In the C programming language and other parts of the Unix world, it is customary to declare constants in uppercase ( eg sngUMSATZSTEUER_ERMAESSIGT for the reduced sales tax rate) - especially in preprocessor macro parameters.

Naming conventions for Java

The programming guidelines for Java set naming conventions for different linguistic elements, regardless of their use. In principle, Java identifiers are written with Binnenmajuskeln ( camel hump notation, Eng. CamelCase called ), and underscores ( "_") included, with the exception of constants ( see below).

  • Class names should be nouns and begin with a capital letter, such as String or ArrayList.
  • Method names should be verbs and begin with a lowercase letter, for example, add or remove. Specifically, query methods often deviate from this rule so far off when they are not verbs, and called instead for example toString or isEmpty.
  • Constant names should be written entirely in capital letters, the individual words are separated by underscores, eg MIN_VALUE.
591435
de