From: Chris Morris Date: 2002-04-10T14:22:18+09:00 Subject: RE: ruby + Creating and extending XML documents > I`m pretty new to Object Orientation, so am I being naive? > Is my approach totally off the mark? I think you've got a good grasp of the benefits of inheritence. You've put the portions that pertain to all documents in a base class, and limited the portions that are more limited in scope to a descendant class. One potential problem: you are coupling your raw data (title, user, etc.) with its storage/presentation in xml. For example, I can add a user to the MasterDocument, but I can't retrieve it same as I put it in, I can only retrieve an xml representation of it. I think if you go much farther feature-wise with your code, you might quickly see the need to decouple the basic data from its xml representation. Then again, it's probably working fine for now, and if that's good enough, it's probably good enough. I'll also plug a project I've been cobbling together. It's a module called XmlSerialization that would allow you to recode your class this way: class MasterDocument include XmlSerialization attr_accessor :title, :user end ... and you can essentially do this still: xml = MasterDocument.new xml.title = "A Page On My Site" xml.user = user # puts xml.document xml.to_xml.write(io) This also allows you to work with the title and user data directly, decoupling the data from its xml rep. You can check it out here: http://clabs.org/clxmlserial.htm. Still in a prerelease stage, but it's functional, I use it in production code on the job. > Have I been smoking too many drugs? More than none is probably too many. Chris