On May 30, 2007, at 12:59 AM, Sergiu Dumitriu wrote: [snip]
Lazy types are not good, as they are storage dependent. Hibernate has this feature, but how about XML Database servers, or JCR? We'd probably have to write our own storage-dependent wrappers.
On the other hand, I'd like *not* to have a storage dependency inside the model classes. The model should only contain data.
The model should only contain data AND behaviors associated with this data. For example I'm pretty confident we want to have Space.getDocuments() for example in the model.
Pros and cons of lazy loading data: Pros - We can reduce the amount of time/memory needed to load a document
Well this is the same as with the other option I believe as for example we would retrieve documents only when Space.getDocuments() get called the first time. Or do you mean something else?
- There's no dependency on the storage inside the model
There's a dependency but it's a runtime dependency rather than a source time dependency.
Cons - We need an intermediate between storage and model (decorator?)
Yes, this requires some magic (byte code enhancement) if you want to make it transparent. Otherwise you need an API to load data and then only you're allowed to use the domain objects, which isn't nice.
- We might have to write the intermediate along with the storage, as not all storage systems support lazy loading. This is not as bad as it looks, because basically we're moving storage.load() from a model class to a decorator class, and the decorator can be storage-dependent.
Can we use JPOX ( http://www.jpox.org/ ) as the decorator for some storage systems? Should we?
Yes we could. I know someone who's using it. I'll check with him. [snip] Thanks -Vincent