I am facing a modelling challenge, which I hope you can provide input on. I will present an idealized version of the problem below:
I want to represent documents (pages) in a CMS. Something like this:
Page
\-*-> Revision
\---> Document
\-*-> Section
\-*-> Paragraph
\---> User
The persistence layer is document oriented. Let's say every revision is stored as a JSON blob. Serialization is required for persistence and a REST API. Serialization/deserialization should be a simple operation, something like serialize( revision ) -> blob
and deserialize( blob ) -> revision
.
So far so simple. However, the CMS should allow plugins that can associate additional information with each bit of the document model. E.g.:
- A social plugin would maintain carma points for each user
- A comment plugin would allow reader comments on every page
- A workflow plugin would associate a state with each page
- A review plugin would allow annotations on each paragraph
- A chart plugin could associate a chart with a paragraph
It should be possible to mix and match such plugins. Each plugin will have to provides at least a mechanism to serialize, unserialize, and display the relevant information (plus an API and UI to interact with it, but that's not central here, I think).
As an additional constraint, I want 3rd parties to fetch the (JSON) representation of a document via the REST API, and conveniently use the data within, ideally using the same deserialization logic that I am using internally.
The question is: how should I design the core model, the classes that represent Page, Revision, Document, Section, and Paragraph? How is that extra info from the plugins associated with the respective parts of the core model? How do plugins integrate their logic for serializing/unserializing/rendering the content with the standard interfaces for these tasks?
PS: I'm not going to write yet another CMS, and I'm not interested in using an existing CMS. The above is an idealized problem, intended to allow discussion of design principles.
Aucun commentaire:
Enregistrer un commentaire