Velocity is the only language where Brevity for Brevity's Sake is OK.
In other languages, reducing total lines of code (LOC) with show-offy shortcuts just means your code will make no sense (to you or anyone else) after a few months away.
But in Velocity, the shortest possible implementation is a smart move, since:
Imagine you had a few Lead fields using the JETDS naming system: installationEnvironment, typeOfEquipment, and purpose.
There are 10-20 options for each of these fields, so the number of total combinations is huge. Even if you're only interested in a subset, the conditions get loooooong...
#*
I'm being generous with whitespace here,
but it's *still* hard to read/maintain!
VTL is whitespace-preserving, so indents are true spaces.
*#
#if( $lead.installationEnvironment == "amphibious" )
#if( $lead.typeOfEquipment == "radar" )
#if( $lead.purpose == "receiving" )
do something...
#elseif( $lead.purpose == "detecting" )
do something else...
#elseif( $lead.purpose == "navigation-aid" )
do something else entirely...
#end
#elseif ( $lead.typeOfEquipment == "sonar" )
#if( $lead.purpose == "receiving" )
do yet another thing...
#elseif( $lead.purpose == "detecting" )
do still another thing...
#elseif( $lead.purpose == "navigation-aid" )
...
#end
#end
#elseif( $lead.installationEnvironment == "ground-mobile" )
#if( $lead.typeOfEquipment == "radar" )
#if( $lead.purpose == "receiving" )
...
#elseif( $lead.purpose == "detecting" )
...
#elseif( $lead.purpose == "navigation-aid" )
...
#end
#end
#end
## etc., etc.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.