Nomenclature Rules Review Options

Top  Previous  Next

 VS   VB6   VBA 

The Nomenclature Rules Review sub-section of the Quality Review section of the Team Options tab allows you create the nomenclature rules to be checked when the Review Quality feature is executed with this review selected:

OptionsNomenclatureRulesReview

The nomenclature rules can use control tags and type tags that are defined in the Control Tags Options and Type Tags Options.

To create a new nomenclature rule you use the following window:

NomenclatureRule

In this window you enter the following properties:

  • Id (optional): an identifier for the nomenclature rule.
  • Description: a brief text describing what the nomenclature rule checks.
  • Item to review: the item whose name is going to be reviewed. It can be any item, project, file, form, any control, any code element, class, field, etc.
  • What to review: you can review the name of an item in several ways.
    • The name must use a convention of prefixes, suffixes and a specific case (Pascal, Camel, all upper case, all lower case). For example, you can define a rule to check that control names start with a custom control tag.
    • The name must meet a condition with an operator and a value or a set of values. For example, you can define a rule to check that interface names start with "I". The condition is defined using a Condition editor.
    • The name length must meet a condition with an operator and a numeric value. For example, you can define a rule to check that variables have more than one letter, to avoid names like i or j. The condition is defined using a Condition editor.
  • When to review (optional): you can define conditions (using a When condition editor) for the review to be executed. You can set that all, any or none of the conditions must be met.
  • Explanation: the explanation tab has the Explanation field to describe in great detail what the review does and the How to fix field to explain to the developer how to rename the item to meet the review.
     

Example

Suppose that you want to create a nomenclature rule like this:

"When a module variable is global, it must be prefixed by "g_" followed by a prefix for its type (such as "i" for Integer, "b" for Boolean, "s" for String, etc.) and its name must use Pascal case"

Correct cases:
 
Public g_sConnectionString As String ' Correct
 

Incorrect cases:
 
Public g_ConnectionString As String  ' Incorrect: missing "s" prefix for String type
Public sConnectionString As String   ' Incorrect: missing "g_" prefix for Public scope
Public g_sconnectionString As String ' Incorrect: Camel case instead of Pascal case
Public ConnectionString As String    ' Incorrect: missing prefixes

 

You would create that nomenclature rule as follows:

  1. Go to the Type Tags Options, and define the type tags for the desired types, such such as "i" for Integer, "b" for Boolean, "s" for String, etc.
  2. Back in the Nomenclature Rules Review Options page, create a new nomenclature rule with these steps:
    1. Click the button "New".
    2. In the field "Description", type "Public module fields must start with the prefix g_, followed by the prefix for its type and must use Pascal case"
    3. In the field "Item to review", select the value "Module Field".
    4. In the field "Prefix 1", type the hardcoded value "g_" (without the quotes).
    5. In the field "Prefix 2", click the "Insert >" button, click the "Predefined Variable..." menu item and select in the list the predefined variable "Type Tag". The field "Prefix 2" will be filled with the value "$P[TYPE_TAG]".
    6. In the list "Case" select "Pascal".
    7. In the tab "When to review" create a condition with these steps:
      1. Click the button "New".
      2. In the list with the object that must meet the condition, select the value "Module Field".
      3. In the list "Property Name" select the value "Access".
      4. In the list "Operator" select the value "One of Selected Values".
      5. In the list "Value", check the value "Public"

The following sample code would produce a nomenclature rule violation for each public variable in the module:

NomenclatureRuleReviewExampleResults

 

See Also:

Review Quality

Quality Review Options

Condition Editor

When Condition Editor