Sunday, July 2, 2023

Developer Best Practices

 Use independent libraries and workflows:

• Write code consistent with best practices

Use independent libraries and workflows:

The best way to avoid issues introduced into common code changes up to the extent possible, instead of introducing your changes directly into a common code source (such as BPK workflow library, BPK Rule library) try to create independent code libraries and sub-process and reference them in common code

Write code consistent with best practices

• Code quality is particularly important because there is a good chance to someone in the future will need to understand it without prior context. Here are some high-level guidelines:

• Follow standard Java conventions and standards

• Use proper indentation

• Comment your code thoroughly

A good rule of thumb is to give high-level comments on what each code block is doing and then comment on anything unusual that you do.

• Write code that is clear and easy to understand

Write your code in a way that is easy to follow logically and consistent with the way you are writing it.

• Keep code performance efficient

• Create or update existing documentation where appropriate

• The code should be reviewed by the team and keep the proper logs statements.


Developer Best Practices:

1. Use proper naming conversation for all variable declarations.

eg: 'Identity idnRequester' or 'int intIdentityCount'.

2. Any connection objects (e.g., database, File, server) must be closed in the final block.

try{

conn= DriverManager.getConnection("");

}

catch(SQLException ex){

handle the exception or throw as a general exception

}

finally{

try{

if(conn !=null){

conn.close();

}

}catch(){

}

}

3. while throwing the exception, wrap with GeneralException along with information causing an exception.

ex: catch(){

throw new GeneralException("occurred while loading the entitlement data",e);

}

4. Don't log for throwing the exception in the catch block, it results in duplicate logs in the log file for the same exception.

ex: catch(illegalArgumentException e){

//log.error(e); do not do this

throw new GeneralException("occurred while loading the entitlement data",e);

}

5. Always check for the Null object while accessing any object.

ex: Identity id= context.getObjectByName(Identity.class,"test");

if( null ==id){

log.error("no identity found);

return ;

}

6. Check for void if you are accessing out of boxes variables in any rules, workflows forms, etc.

7. Check for object instances if you need more clarification on the run time object.( instanceof List or instanceof String).

8. Try to avoid logic in workflow steps, call as a method from a rule.

9. Try to avoid saving complete objects in workflow parameters until it is really required.

10. Make sure while deploying the code in production the trace parameter is set to false.

11. Do not print complete objects as info or error. do it in debug.

12. Be a practice of using separate logger objects for each rule.

eg: Logger log= Logger.getLogger("");

13. Always use context.search with specific columns while loading data.

14. Avoid using IIQ objects as variable names.

15. Flush the iterator once it is done with the logic. This will release the cursor object related to the database.

ex: Util.flushIterator(itername);


16. Decache the loaded objects once done with the operation.

context.decache(obj name);

17. Default imports for bean shells. Do not add imports explicitly.

java.net.*;

java.lang.*;

java.util.*;


18. Do not print passwords in logs, put password generation in before the provisioning rule and try to implement encrypt mechanism.

19.Do not log any "sailpoint object data "(Ex.log.debug(plan.toXml()), log.debug(project.toXml()).

20. Do not log any authentication token at any level.

21. If you are referring to any rule in your new rule, refer to all the rules references of the parent rule as well.

Fetch Members from Workgroup

  import java.util.ArrayList;   import java.util.Iterator;   import java.util.List;   import sailpoint.api.ObjectUtil;   import sailpoint.ob...