Nov 4, 2021 2:31:06 PM Thomas Dumont avatar

Naming rules

All naming rules described here must be verified using the Checkstyle and PMD tools. These tools must be configured to support specific naming rules, using the configuration files provided by the Lutece project.

General principles

The names of the identifiers must respect the following rules:

  • Be names commonly used to refer to the object
  • Do not introduce any misinterpretation or interpretation problem
  • Being in the English language
  • Never be truncated or contracted

Do not use constants or variables to store hard error messages (use dedicated properties files). As a rule of thumb avoid any hard value, make maximum use of the .properties properties files of the application or plugins.

Do not use absolute paths (the only absolute paths used are stored in the existing settings of the config.properties file).

Variables

The basic types of Java must have the prefixes following:

PrefixesType
N int
Str String
B boolean
The Long

The object instances must be prefixed by the name of the class or the part representative of the name of the class indicating as precisely as possible the type of object.

Class Sample instance of the class
HtmlTemplate tlist
StringBuffer sbXml
Date dateBegin
List, ArrayList listUsers

Formatting: Hungarian notation except initial in lowercase, no underscore. Abbreviations are to be avoided.

Instance variables ( static or not) must be prefixed with an underscore.

Constants

Any string literal or numeric value must be placed in a constant . Statements of constants must be made in the first lines of the source or in a special class dedicated to constants.

Prefixes must indicate the nature of the constant.

The current prefixes are:

Prefixes Type
ACTION_ For an action of the MVC
DSKEY_ For Datastore keys
JSP_URL_ for JSP urls
MARK_ For names of bookmarks to substitute in templates
MESSAGE_ For messages or message keys used by Message.jsp
PARAMETER_ for the name of a parameter of the HTTP request
PATH_ For directory paths
PROPERTY_ For the key names of a .properties file
TEMPLATE_ For names of HTML templates
VIEW_ For a view of the MVC

Formatting constants: all capitalized, words separated by underscores.

For a plugin of a certain size, the constants can be grouped together in a class fr.paris.lutece.plugins.myplugins.web.Constants .

Database objects

All table and column names must be lowercase, separating words by underscores. All table names must be prefixed by plugin_ name except for tables kernel that are prefixed by core_.

SQL queries

SQL queries for DAO classes (business layer) must be be placed in variables of type string and must comply with the following form:

  • uppercase keywords (SELECT, UPDATE, WHERE, AND ...),
  • names of columns in lowercase,
  • aliases column names as letters of the alphabet

Syntax example:

String strSQL = SELECT a.id_theme, a.description_theme FROM theme a, theme_newsletter WHERE a.id_theme = b.id_theme and b.id_newsletter =? ;

Template files

Extension: .html

Formatting: all lowercase, words separated by underscores, no dashes, English language, no abbreviations.

Naming rules for files for processing standard:

  • create_functionality.html for displaying a creation page,
  • modify_functionality.html for a modification page,
  • remove_functionality.html for a page allowing deletion,
  • manage_functionality.html for displaying a management page of a feature,
  • view_functionality.html for a listing page, confirm_feature.html for a confirmation message page,
  • feature_list.html for a page displaying a list.
  • feature_row.html for displaying a line of a list.

Bookmark naming rule for Bookmark value substitution: English language, lowercase, words separated by underscores, no abbreviations or dashes. (ex: $ {file_name} )

JSP files

Formatting: Hungarian notation, English language, no abbreviation, no dashes, no underscore;

Naming rules for files used for standard display processing:

  • CreateFunctionality.jsp for pages used for creation page display processing,
  • ModifyFunctionality.jsp for pages used for editing page display processing,
  • RemoveFunctionality.jsp for pages used for delete page display processing,
  • ManageFunctionality.jsp for pages used for management page display processing,
  • ViewFunctionality.jsp for pages used for page display processing of the feature's form,
  • ConfirmFunctionality.jsp for pages used for display processing of the confirmation page,
  • List.jsp functionality for pages serving list view processing.

Same naming rules for processing Jsp without display, plus Do prefix (ex: DoCreateFunctionality.jsp , DoModifyFunctionality.jsp ...)

Image files

Naming rule: English language, use of lowercase and underscores between words, no hyphens or abbreviations. The prefixes used must match the function of the image when it exists:

PrefixesType
b_ Button Images
i_ Images used as icon (ex: i_delete.png)
l_ Pictures of a line

The format of the images used for the presentation of the pages must be in .png format.

XML files

The XML tags used in the application must be lowercase, separated by hyphens when it comes to compound words, in English, without abbreviations.

The names of the tags should be as close as possible to the model they should represent: for example "portlet-id" for the tag storing the value the portlet identifier retrieved from the portlet column of the portlet table.