ATG Coding Best Practices in writing a Function

Below listed few best practices while writing a Function.


Function should not exceed more than 40 lines and should not perform more than one operation.

Don’t pass more arguments(try to limit the maximum number by 5 ), as parameter in function with out valid reason.

Since resolving a component is costlier and risky,always pass request and session scope objects to global scope component methods instead of resolve component.

Declare variable in the beginning of block where you are
planning to use it.

Initialize local variables where they’re declared.

You should not locally re-declare a member variable while coding for a Function.This will gradually hide the visibility of 
member variable.

Do not directly access variable, instead use getter functions
If a variable has been created only for a loop, use suffix 'temp' to let others know that the variable will be used only
to store data temporarily. such variable should be declared 
null at beginning of method and initialized only when they are needed.


See ATG Form Handler Best Practice

Comments

Popular posts from this blog

Weblogic Issues during EAR Deployment Exception in AppMerge flows progression

BCC site status inaccessible Agent Production in error state

DUseSunHttpHandler=true weblogic.net.http.SOAPHttpsURLConnection Weblogic/Java HttpHandler issues