/
Calling Library Functions with Aliases
Calling Library Functions with Aliases
To improve readability, always assign the library element instances to a variable before using them:
final roundingUtils = libs.MathLuib.RoundingUtils
final someNumber = ...
roundingUtils.round(someNumber, 2)
This practice dramatically improves the readability of your code as it grows in size.
Do this:
final productUtils = libs.ProductLib.ProductUtils
final pricinUtils = libs.PricingLib.PricingUtils
final product = productUtils.getProduct(...)
final cost = productUtils.getCost(...)
final margin = pricingUtils.getMargin(...)
final listPrice = pricingUtils.calculatePrice(product, cost, margin)
Don’t do this:
final productUtils = libs.ProductLib.ProductUtils.getProduct(...)
final costUtils = libs.ProductLib.ProductUtils.getCost(...)
final marginUtils = libs.PricingLib.PricingUtils.getMargin(...)
final listPrice = libs.PricingLib.PricingUtils.calculatePrice(product, cost, margin)
, multiple selections available,
Related content
Recommended Logic Structure for Line Item Calculation Logics
Recommended Logic Structure for Line Item Calculation Logics
Read with this
How to Round Numeric Value
How to Round Numeric Value
More like this
Coding Style
Coding Style
Read with this
Explicit Function Parameter and Return Types
Explicit Function Parameter and Return Types
More like this
Source Code Auto Formatting
Source Code Auto Formatting
Read with this
Best Practices
Best Practices
Read with this
Found an issue in documentation? Write to us.