Pages

Thursday, June 14, 2012

ADF Coding Standards & Check points

For any ADF Java code, Model and UI layer, here are few points to make code better from writing from performance and standard point of view, that comes from our coding practice and experience.

There is a set of checkpoints we should check before source controlling any changes.This ensures making code better, robust, standards compatible and more performant.

JSFF/JSPX code - Check points
  • Make sure, you have used Resource Bundle where ever its required.
  • For Bounded taskflows, make sure to use activation as conditional/deferred (Not Immediate) and use active condition EL expression.
  • Id of the component, length should be <= 7.
  • Make sure, you have removed unwanted PageDef Bindings.
  • If af:popup is used, make sure to set the contentDelivery to "LazyUncached".
  • If using af:contextInfo, make sure the af:dialog has modal="false".
  • If using af:contextInfo, make sure the af:showPopupBehavior has triggerType="contextInfo".
  • If using af:popup from af:commandLink, make the partialSubmit to true for af:commandLink.
  • If using af:popup. make childCreation property to "deferred" so that only when the Popup is launched the WebBean hierarchy would get created in server memory.
  • Run JAudit for the file you make changes, from Menu->Run->JAudit file.
  • Right click->Reformat before checkin.
  • If using JavaScript, can you think to avoid that.
  • jsff/jspx files must reside under /page package.
  • Taskflows must reside under /flow package.
  • Menu model xml files must reside under /menu package.
  • In Case of deriving the Url parameters, preferably use the following syntax to derive declaratively #{facesContext.externalContext.requestParameterMap['Empno']}
    (Empno is url parameter)

Any Java Code - Check points
  • Managed Bean class name should end with "Bean".
  • Don't use SOP statements.
  • New methods introduced, make sure they are modular so that they can be JUnitized.
  • New Method should always return a value so that they can be JUnitized.
  • Add Logger statements to the new methods.
  • Make sure you have thrown sufficiently Exceptions.
  • Run JAudit for the file you make changes, from Menu->Run->JAudit file.
  • Make sure to define the Variables with a name starting with small letter.
  • Do not use underscore (_) in Variable and Method names.
  • Make sure to check for Null condition for all operation that could throw NullPointerException. Ex: CollectionModel, Row, ViewObject, ApplicationModule, String objects etc.
  • Right click->Reformat before check in.

Application Module(AM) - Check Points
  • Make sure to Use JNDI datasource instead of JDBC URL in the AM configuration(i.e bc4j.xcfg)
  • Number of occurrences of createRootApplicationModule() or *AMImpl.getInstance() should be same as releaseRootApplicationModule(). 

Entity Object - Check Points
  • Can you convert the code you have just written into Groovy?
  • Run JAudit for the file you make changes, from Menu->Run->JAudit file.

View Object - Check Points
  • Get SQL explain plan every time you touches a VO.
  • For new Attributes added, make sure you use proper UI hints.
  • If creating a New VO, make sure its is based on an EO (Exceptions to be considered).
  • If createViewObject calls are present, then make sure, you remove those dynamic ViewObjects.
  • If setting rangeSize() to -1, restore the rangeSize after you work on that.
  • Don't set ListRangeSize == '-1' unless the ViewAttribute using the LOV has CONTROLTYPE 'choice' or 'radio' or 'default'
  • FetchSize should be <= 25 or same as number of rows to be displayed in UI.
  • Avoid use of vo.getRowCount()
  • View Criteria shouldn't have "null checking" checkbox checked.
  • LOVs shouldn't have "query automatically" checked.
  • SQL based VOs,should have query optimizer hint set to "FIRST_ROWS(10)".
  • Always test the application with ampooling= false when our bc4j transaction involves any transient VO's.

Most of the above points were shared with me by one of my superior(Amulya Mishra) when I was a novice ADF developer. So, thought this check list will be helpful for other novice developers, like it helped me :)

1 comment:

  1. nice points good. i personally appreciate you both the peoples

    ReplyDelete