Re: Future Proofing/Backward compatibility

2012-12-11 Thread Dave Merrill
+1 for Cameron's approach. I use that construct in lots of places internally to create value objects with default values for keys that weren't passed. Dave Merrill On Fri, Dec 7, 2012 at 9:42 AM, Cameron Childress wrote: > > On Wed, Dec 5, 2012 at 6:50 PM, Chris Velevitch > wrote: > > > How wo

Re: Future Proofing/Backward compatibility

2012-12-07 Thread Cameron Childress
On Wed, Dec 5, 2012 at 6:50 PM, Chris Velevitch wrote: > How would you design that function to handle the fact that some > clients are NOT passing the new field and there's no need to change > the clients as it's optional? I typically handle this in a CFC function using defaults for non-require

Re: Future Proofing/Backward compatibility

2012-12-06 Thread .jonah
Depending on which versions of CF you need to support, you could do either: value = iif(structAppend( struct, { 'new_field' = 0 }, false ), de(struct.new_field), 0); or value = structAppend( struct, { 'new_field' = 0 }, false ) ? struct.new_field : 0; As a side note, I though iif() was slow, bu

Re: Future Proofing/Backward compatibility

2012-12-05 Thread Chris Velevitch
On Thu, Dec 6, 2012 at 11:27 AM, .jonah wrote: > value = structAppend( struct, { 'new_field' = 0 }, false ); Interesting solution, however, value needs to be struct.new_field, structAppend returns true/false and not the resultant struct. I'm trying to do this inline. It would be good if structA

Re: Future Proofing/Backward compatibility

2012-12-05 Thread .jonah
You can also do: value = structAppend( struct, { 'new_field' = 0 }, false ); On 12/5/12 3:50 PM, Chris Velevitch wrote: > value = > "#iif(StructKeyExists(struct,'new_field'),Evaluate(DE('struct.new_field')),0)#" ~| Order the

Future Proofing/Backward compatibility

2012-12-05 Thread Chris Velevitch
Let's say I have a cfc I'm using to provide a service to multiple disparate clients. One of the arguments to a function is a struct. That struct is then used to pass values as individual arguments to a stored procedure on a database. Now the stored procedure is changed to add a new optional param