Comments on: Cairngorm Top 5 Tips – Number 3 – The Data Translator Pattern http://www.adamflater.net/2009/02/02/cairngorm-top-5-tips-number-3-the-data-translator-pattern/ Tech, UX, Design Wed, 04 Jan 2012 21:31:56 +0000 hourly 1 http://wordpress.org/?v=3.5.1 By: Anonymous http://www.adamflater.net/2009/02/02/cairngorm-top-5-tips-number-3-the-data-translator-pattern/#comment-228 Anonymous Sun, 14 Feb 2010 01:20:23 +0000 http://www.adamflater.net/?p=71#comment-228 Interesting article you got here. It would be great to read something more concerning that theme. Thanx for giving that data.

]]>
By: Tony Smith http://www.adamflater.net/2009/02/02/cairngorm-top-5-tips-number-3-the-data-translator-pattern/#comment-227 Tony Smith Wed, 11 Mar 2009 22:10:00 +0000 http://www.adamflater.net/?p=71#comment-227 Nice post! I was just wandering the halls of Google results for a great idea for handling XML in cairngorm. I can’t wait to try this out. Thanks for contributing.

]]>
By: Adam Flater http://www.adamflater.net/2009/02/02/cairngorm-top-5-tips-number-3-the-data-translator-pattern/#comment-226 Adam Flater Wed, 25 Feb 2009 06:38:00 +0000 http://www.adamflater.net/?p=71#comment-226 @Eric

Thanks for the comment. That’s a cool approach.. If you blog about it, be sure to link from this post. Theoretically I’m a big fan of IoC like this, but practically I find that the data translation layer doesn’t change that often. However, every app is different and if it’s an easy pattern to implement the added flexibility is definitely a nice-to-have.

Thanks again
-adam

]]>
By: Eric http://www.adamflater.net/2009/02/02/cairngorm-top-5-tips-number-3-the-data-translator-pattern/#comment-225 Eric Wed, 25 Feb 2009 06:35:00 +0000 http://www.adamflater.net/?p=71#comment-225 Hi Adam,

Very nice example, and thank you for taking the time to post on Cairngorm related topics – as there hasn’t been much blogging going on in this space for some time.

I essentially use the same pattern of data translation and abstraction but with a factory implementation. Whats nice about this approach is you can leverage Dependency Injection to configure the Factories, so for example, if we needed to translate our domain models to another format other than XML we can do so by changing the Factory implementation via the IoC container. In this way client code need not be modified as the change would be implemented transparently to the clients implementation.

Best,
Eric

]]>
By: Adam Flater http://www.adamflater.net/2009/02/02/cairngorm-top-5-tips-number-3-the-data-translator-pattern/#comment-224 Adam Flater Mon, 02 Feb 2009 16:58:00 +0000 http://www.adamflater.net/?p=71#comment-224 @Anonymous

Well… you really can’t. If you want typed objects, you need to know the schema before compile time.

]]>
By: Adam Flater http://www.adamflater.net/2009/02/02/cairngorm-top-5-tips-number-3-the-data-translator-pattern/#comment-223 Adam Flater Mon, 02 Feb 2009 16:56:00 +0000 http://www.adamflater.net/?p=71#comment-223 @danielggold

Yeah man.. a proxy technique is great in this case. The only gotcha is if you have large volumes of data you’ll use even more ram due to the additional object instances for all the proxies.

Optimization is always a trade off. In the wrapper solution you use more ram but defer execute. In the data translator solution more processor time is used up front with the gain of less ram used and faster access to the data.

As I said in the post, a good engineer considers the many viable solutions to this problem on the basis of what you’re trying to accomplish in your application.

Cheers
-adam

]]>
By: Anonymous http://www.adamflater.net/2009/02/02/cairngorm-top-5-tips-number-3-the-data-translator-pattern/#comment-222 Anonymous Mon, 02 Feb 2009 13:10:00 +0000 http://www.adamflater.net/?p=71#comment-222 How would you go about parsing an arbitrary XML document that you don’t and can’t know its structure?

]]>
By: danielggold http://www.adamflater.net/2009/02/02/cairngorm-top-5-tips-number-3-the-data-translator-pattern/#comment-221 danielggold Mon, 02 Feb 2009 05:50:00 +0000 http://www.adamflater.net/?p=71#comment-221 One of my preferred ways of dealing with this since I’m usually working with XML data coming off a service bus is to have my VOs “wrap” the XML instead of translating back and forth at the delegate layer. The getters/setters deal with expected data types but underneath they’re manipulating the received XML using e4x. Of course it all depends on where the application is doing the heavy lifting, but imagine translating a hundred objects, setting a property on a few of them, then translating back to XML at the service layer. If you keep it native XML underneath and wrap then you’re only dealing with the overhead of e4x on the properties you’re accessing.

]]>