Naming convention (data processing)
Naming conventions are specifications / requirements / recommendations for programmers , database developers , etc. to name identifiers (names) for objects in the source code of software . When they are used, the names of these objects - within the framework of the syntax provisions of the programming language and also across programs - should be formed according to uniform rules, whereby the software quality feature changeability (maintainability) is supported by easier understanding of the program text.
Such rules apply - mostly company- or project-specific - constructs generally used for all programming - such as data fields ( variables , constants ), objects , functions , types , classes , modules , procedures , command text sections, etc. and are intended to be "readable code" contribute .
Naming conventions are structurally / methodologically part of the programming guidelines and a. the programming style for the program code. Depending on the situation / company, they can be binding or formulated for voluntary use.
In the Microsoft world, the so-called Hungarian notation was used in the past , in which the beginning of an identifier can be used to infer its type or purpose. In the meantime, however, Microsoft prohibits the use of Hungarian notation. Instead, variables should be named according to clean code guidelines.
Coding of the type in the name
bytZaehlerfor a counter variable of the byte type (up to size 255),
intZaehlerfor a counter variable of the type integer (from −32768 to +32767),
lngZaehlerfor a counter variable of type long (> 32767),
sngQuotientfor the floating point result of a division of the type Single,
dblQuotientfor the floating point result of a division of the type Double,
curNettofor currency amounts of the type Currency,
strVornamefor alphanumeric strings of the string type,
Coding of the use in the name
tblKundefor a table containing customer master data,
qryPLZ4for a query that collects all customers from the postcode area 40000 to 49999,
frmAuftragfor a form in which customer orders can be entered / displayed / changed / deleted,
repUms2005-12_Knd1010for a report in which all sales of the customer with customer number 1010 are listed, which were made in December 2005.
Constants in C
In the C programming language and other parts of the Unix world, it is common to declare constants in capital letters (e.g.
sngUMSATZSTEUER_ERMAESSIGTfor the reduced sales tax rate) - especially for preprocessor macro parameters.
Naming conventions for Java
The programming guidelines for the Java programming language define naming conventions for various linguistic elements, regardless of their use. Basically Java identifiers are with medial capitals are written (even camel hump notation , Eng. CamelCase called) and no underscores ( "_") included, with the exception of constants (see below).
Class names should be nouns and begin with a capital letter, e.g. B.
Method names should be verbs and begin with a lowercase letter, e.g. B.
remove. Query methods in particular often deviate from this rule in that they are not verbs and are instead called, for example,
Constant names should only be written in capital letters, with the individual words separated by underscores, e.g. B.
Reddick naming conventions
More naming rules
Further specifications or recommendations for naming objects in the source text, often only intended as recommendations, can be:
Speaking object identifier
For constructs that are addressed in the programming via identifiers , naming conventions can be used to specify that these are largely selected as "speaking". This means that the identifiers (in the context of the program environment) should be more or less "self-explanatory" in order to show the semantic meaning and use of the elements to people who were not involved in the initial development of the program .
In addition to and more precisely to purely colloquial identifiers (such as "invoice amount"), it can be specified, for example, whether the identifier can / should consist of several parts (e.g. to differentiate between objects in different roles), whether format information should be included in the object description the order in which name parts are to be arranged, whether individual components of the identifier z. B. with a hyphen or an underscore or separated whether abbreviations are to be used.
Example with counterexample:
MWSt_Betrag = Rechn_Betrag_Nto * MWSt_Prozentinstead of
Betrag1 = Betrag2 * Prozent
In the early days of data processing - e.g. B. by programming languages or the use of punch cards - existing restrictions in the length of identifiers are usually no longer relevant in today's systems.
Other naming concepts
In programming, it is common to use descriptive names to identify several other (relatively independent) properties of the elements in addition to the functional meaning in the application (the semantic meaning), for which some common concepts of prefixes / suffixes in the identifier have emerged:
- Data types
- Indirection - reference types also references or pointers called
- Visibility / scope / changeability
- Speaking name (other areas in which meaningful names are used)
- Talking key
- Variable (programming)
- Comment (programming)