The following style recommendations are made to help keep code readable and familiar across the Identity Panel Suite.
- Treat all values as case-sensitive, even when they're not (e.g. function names, attribute or silo names in Graph objects)
- Use C style CamelCase naming for custom functions and environment variables
- Use spaces after commas, e.g.
And(AD.displayName, Or(1, 2))instead ofAnd(AD.displayName,Or(1,2))
- Do not use spaces around = e.g.
Dict(a=1, b=2)instead ofDict(a = 1, b = 2)
- Split long function calls with newlines.
- Left justify all parameters at the same function level.
- Use 2 spaces to indent. Don't use tabs.
- Use custom fuctions to express complex logic in fields that take a single-line entry
- If a custom function requires more than 3 parameters consider passing a structured object:
MyFunc(hv)instead ofMyFunc(emplType, emplStatus, givenName, preferredName, surname)
- When calling a custom function with multiple parameters consider using named arguments (remember a named parameter cannot span multiple lines):
MyFunc( name=FirstNotNull(HV.preferredName, HV.givenName), status=HV.isActive )instead ofMyFunc( FirstNotNull(HV.preferredName, HV.givenName), HV.isActive )
- Use multiple custom functions to avoid excessive length (e.g. split logic if function will exceed 6-10 lines), or if a branch of at least 3 lines is replicated more than once.
-
And( Or( If(thing, this, that), "nevermind" ), "other thing" )
- Prefer boolean functions to boolean operators
And() Or()intead of&&, ||
- Avoid unecessary parentheticals:
And(true, false)instead of(And(true, false))
- Prefer string interpolation to concatenation:
$"{HV.upnPrefix}@{special.Environment.UPNSuffix}"instead ofHV.upnPrefix + "@" + special.Environment.UPNSuffix, remembering that nested interpolation is not supported.
- Prefer
// line commentsto/* block comments */. The comment should start the line.
- When transforming lists, use list reducers in the inner loop to reduce processing:
Map( Filter(list, expression), transformation )
instead ofFilter( Map(list, transformation), expression )
Comments
0 comments
Please sign in to leave a comment.