I do agree with that Tom. It's not worth returning an array of objects for something very simple like that. A query does the job in those cases every time.
It's just when working with more complex data that the ability to model comes into its own, especially when using Brian Koteks dependency injector to automagically wire beans directly into the decorators. I find it hard to think in terms of queries in those cases just because the nicely encapsulated business logic in the Transfer objects makes development that much smoother. It's certainly a balancing act though on larger sites to ensure that memory usage doesn't become an issue. Good point about changes outside of Transfer. I have a legacy admin system I've built over the years that I still use which isn't Transfer aware. However, I have some post-processing hooks that make calls to my service layer to clear the cache of objects when my admin system changes the underlying database record. That seems to work quite well but it something to keep in mind as it can become very frustrating when data on the frontend is suddenly not changing. --- James Allen E: [email protected] Blog: http://jamesallen.name Twitter: @CFJamesAllen (Coldfusion / Web development) Twitter: @jamesallenuk (General) Twitter: @JamesAllenVoice (Voiceover) From: [email protected] [mailto:[email protected]] On Behalf Of Tom McNeer Sent: 28 September 2010 20:02 To: [email protected] Subject: Re: [transfer-dev] Re: listByProperty with Relationships David, I'm not certain exactly what you mean about the number of function calls, but depending on how your application scales, you may need to be careful of the number of objects you're instantiating. James is correct, in that Transfer has a solid cache mechanism. (Though you need to remember that Transfer _is_ caching objects. If you update database records outside Transfer, you can get the cache out of sync with the database.) And object instantiation has improved markedly over the past versions of CF. (Don't know which one you're using.) But instantiating an object is _still_ more expensive than just doing a query, if for no other reason than Transfer has to run the query, then populate the object. You have to get the record out of the database at least once for its object to be in the Transfer cache. So there are certainly instances when queries are a better option. For example, your basic States select box in a Name/Address form. Sure, you could retrieve all the IDs from your States table and loop over them, creating an array of State objects, then use that to populate your select box. But why? You don't really need the objects. Better to do: transfer.list("util.state","stateCode"), and get a regular old CF query object. As I said before, there are times when you need objects, and times when a simple CF query is better. You'll work it out as you spend more time with Transfer. -- Thanks, Tom Tom McNeer MediumCool http://www.mediumcool.com 1735 Johnson Road NE Atlanta, GA 30306 404.589.0560 -- Before posting questions to the group please read: http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions -on-transfer Try out the new Transfer ORM Custom Google Search: http://www.google.com/cse/home?cx=002375903941309441958:2s7wbd5ocb8 You received this message because you are subscribed to the Google Groups "transfer-dev" 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/transfer-dev?hl=en -- Before posting questions to the group please read: http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer Try out the new Transfer ORM Custom Google Search: http://www.google.com/cse/home?cx=002375903941309441958:2s7wbd5ocb8 You received this message because you are subscribed to the Google Groups "transfer-dev" 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/transfer-dev?hl=en
