From: Jeff Cohen Date: 2006-02-14T04:11:01+09:00 Subject: Re: OO Design Advice unknown wrote: > I'm trying to master the more subtle elements of Rubyish OO design, and > am having trouble with the following aspect: > > I have a complicated, nested, value object ( eg > order.customer.address.zipcode, or order.product[0].description). > > This object needs to be sent to various feeds (usually XML, sometimes > REST / HTTP form ) run by other companies. I say, you should definitely abstract away the "rendering" of the data from the data model itself. I would recommend reading up a bit on the "strategy" design pattern, but basically the idea is to take something that varies (i.e. your feed formatting) and separate it from the things that don't vary (your data model). So to render your data for a particular feed, you just instantatiate the particular renderer that you need for that feed, pass it an instance of your data, and then let the renderer worry about all of the formatting. Make sense? I can elaborate more if that would be helpful. Jeff www.softiesonrails.com -- Posted via http://www.ruby-forum.com/.