Naming conventions make programs more understandable by making them easier to read. In addition to the Java naming conventions, Pricefx has its own set of recommended naming conventions for logics and metadata.
Logic Names
Logic names should be written in CamelCase, with the first letter capitalized, for example:
DefaultLogic
Pricelist
Main
DefaultQuoteLogic
However, there are a few exceptions for the following types of logic:
Logic type | Formula Nature | Prefix | Suffix | Example |
---|---|---|---|---|
Calculation Flow |
| CF_ | CF_RebateRecords | |
Calculated Field Set |
| CFS_ | CFS_ProductEnrichment | |
Dataload |
| DL_ | DL_ProductCost | |
Groovy Library |
| Lib | SharedLib |
Element Names
Element names should be written in CamelCase, with the first letter capitalized, for example:
NewMargin
SalesPrice
During deployment, the Groovy logic element scripts get compiled into classes. During logic execution, the logic engine instantiates singleton objects from those classes. These objects then get bound to variables with the same name as the elements. Thus, to call a method callMethod()
that is located inside an element ElementName
:
ElementName.callMethod()
Pricefx Studio will make IntelliJ interpret this as a static call – even though it’s not – and that will make the auto-completion work.
Unique Element Names Within Projects
Element Names should also be unique within the entire project – across all logics. This is to enable the auto-completion and unit testing with TDD4C.
When running the logic locally, the element classes will belong to the default pages. The JVM requires classes within the same packages to be unique, so this will make the local compilation fail.
Libary Elements
Groovy library element names should be suffixed with Utils, for example:
RoundingUtils
CacheUtils
DatamartUtils
Common Patterns
Across logics and entire projects, some patterns of element behavior tend to emerge. For these elements, here are some suggested naming conventions:
Suffix | For | Example Element Name | Example Label | Example Value |
---|---|---|---|---|
Diff | Elements that represent a difference, i.e. a result of a subtraction | VolumeDiff | Volume ∆ | 234 litres |
Abs | Elements that represent an amount of money, in absolute terms. | MarginAbs | Margin $ | €34 |
Pct | Elements that represent a quotient. These elements are typically formatted as percentages. | MarginPct | Margin % | 0.45 Despite the naming convention, the value should not be a percentage, i.e. it should not be multiplied by 100. |
s | Elements that represent a collection. | pxRecords |
Element Labels
Labels should be identical to the element names, but with the words separated by spaces. Some words can be replaced by symbols, for example:
SalesPrice – Sales Price
MarginPct – Margin %
Margin Abs – Margin €
Element labels are optional for those elements that are hidden for the end-users.