Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

  • CRITICAL: Copy pasting the code is not allowed, functions should be utilized
  • All code reflects the auto-format; always use curly brackets for if, for, while. See Unified Code Style and How to Auto Format

  • Avoid api.local, api.global where possible (use a dedicated element, this will help you to trace the logic more easily). Forbidden to use in functions (except special meaning like caching).

  • Use out.SomeElement prior to (deprecated) api.getElement("SomeElement")
  • Use input.SomeInputName prior to (deprecated) api.input("SomeInputName")
  • Use real data type when declaring the variable instead of def. Mandatory use in functions - both parameters and the return type!
  • Use field names in filters or use api.namedEntities() if possible

  • Prevent api.isSyntaxCheck Issues by having AbortSyntaxCheck element in the logic
  • Follow the Recommended Logic Structure
  • Use https://pricefx.atlassian.net/wiki/spaces/DEV/pages/2946629934/Input+Builders

  • Smartly use of @Field constants (no use for fields, table names, configurator names in customer projects). Mandatory use for important values used in conditions or in accelerators.
  • Use api.findLookupTableValues("TableName") instead of api.find("MLTVx", ...)

  • Use one approach for adding item to the list, do not mix the approaches. Recommendation is to use List << value prior to List.add(value)

  • Use the same approach for accessing List item, do not mix the approaches. Recommendation is to use List[index] prior to List.getAt(index)
  • Use the same approach for accessing Map values, do not mix approaches. Recommendation is to use Map.key prior to Map[key] or Map.get(key)
  • If casting is needed e.g. ?.toBigDecimal() for amounts (never floats!), do this on the first occurrence of the variable

  • Use closures (collect, collectEntries, each, eachWithIndex, max, min, inject, sort, etc.) whenever applicable. Note: utilize use of sortBy parameter in api.find() prior to sort() closure for a better performance.
  • Use "find" (resp. "query") prefix for the name of a function that is querying PB tables (resp. PA datasources/datamarts) Do not mix data querying and calculation in the functions
  • Use the method library alias when calling several Groovy library function in the element or function: def CurrencyUtils = libs.MainLib.CurrencyUtils
  • PERFORMANCE: avoid returning big data in an element. Remember: in Groovy, the expression on the last line is the value returned!
  • Split suuuuperlooooong lines.
  • Initialize Map directly. Instead:

    directly use (and following auto-format):


  • Analogically, initialize List directly. Instead:


    directly use (and following auto-format):

  • No labels