Can someone please explain to me once and for all what the purpose of a DataObjectDecorator is? What is the advantage of creating GalleryFile as a decorator of File over just creating a subclass of File? What is the advantage of creating ForumMember as a decorator over just subclassing Member?
AFAIK, the difference is that it affects all the existing uses of the class, so code which uses the File class is in effect using GalleryFile class. This allows you to extend core classes without changing the core files themselves.
Yeah, that makes sense. But if a GalleryFile can only belong to a GalleryPage, and if a ForumMember can only belong to a Forum, then why not just use subclasses? A gallery page has many GalleryFiles, and a Forum has many ForumMembers. I mean, why would all your other instances of File need access to those new fields, anyway?
Oh well.. thanks for the explanation. I think I get it now. I just need to find a use for it.
A use that I can think of off the top of my head is that modules can add functionality to existing classes without modifying their code. For example the ecommerce module can add extra address fields to the Member class.