With the new ways of writing CFC in CF9, what are some of the coding convention new to CF9?
Here are some I can think of...
- always use LOCAL scope
- always include
init()
method that returns itself, sinceNew
will call init() if found. - do not put required arguments in
init()
if it is an ORM entity, otherwise expect Exceptions... - always use
THIS.setXXX
in where XXX is property name inside init(), so that it will call the implicit setters or custom setter if available. - abandon the pre-CF8 INSTANCE scope convention, see: http://henrylearnstorock.blogspot.com/2009/08/should-we-abandon-instance-scope-in-cf9.html
- no output=false for component and functions in script style CFC, see: http://www.coldfusionjedi.com/index.cfm/2009/8/26/Ask-a-Jedi-Impact-of-whitespace-and-script-based-CFCs
- use the cleaner and more efficient
isNull(arguments.optionalArg)
instead ofisDefined()