By front-computing all those values, you're necessarily doing a LOT of extra work to build up data that isn't needed universally. A dataDiff for age is simple, but what if it's numberOfGrandchildren (which is guaranteed to require database access to answer). Using a method for lazy loading the data can be a HUGE performance boon, as well as moving a huge amount of entity-specific logic into the entity (rather than in external components divorced from the entity itself).
But like you said to Peter, I think we have to agree to disagree on this. :) cheers, barneyb On Fri, Jan 7, 2011 at 6:33 PM, Steve Bryant <[email protected]> wrote: > >> Rather than just reconsidering the rule, you might simply replace it >> with "no multi-term expressions in the view". Not a viable goal in >> all cases, but pretty darn close. Views shouldn't have logic apart >> from that directly concerned with the view structure (looping rows in >> a table, conditionally displaying an action button, etc.). All the >> dynamic values and conditional expressions should be single terms >> (often - usually? - a method call): >> >> #person.getAge()# >> not >> #dateDiff('yyyy', dateOfBirth, now())# >> >> <cfif person.isMinor()> >> not >> <cfif person.getAge() GT AGE_OF_MAJORITY> >> >> cheers, >> barneyb > > For me, I would probably pass AgeOfMajority into my service component and > have it return an "isMinor" column. If that wasn't a possibility, then I > would have my page controller add that column to the query. > > I would also have an "age" column in the query returned from the service > (assuming it was in the fieldlist). > > I like a clean view with no method calls. > > Steve > > -- > You received this message because you are subscribed to the Google Groups > "CFCDev" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/cfcdev?hl=en. > > -- Barney Boisvert [email protected] http://www.barneyb.com/ -- You received this message because you are subscribed to the Google Groups "CFCDev" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/cfcdev?hl=en.
