DCI (data, context, interaction) persistence example
All the examples of DCI I've seen seems to be based on the object as the ultimate holder of information, and 开发者_开发知识库the transaction boundaries are defined inside the methods.
I would like to see an example of a persistent application, where there is some sort of persistence layer, i.e. where there can be duplicate object copies of the underlying persistence storage and where a change to an object is a change to a copy that will later be persisted. Does DCI work for that model at all?
DCI is a paradigm and just as you can build an application using any other paradigm with persistence (execluding pure FP since persistence is a side effect) so can you with DCI. It's not mentioned in DCI examples because it's not a concern to the paradigm and is unrelated to understanding the paradigm. (That said you're not the first to ask the question and will not be the last I'm sure).
The concern of persisting data is in general ortogonal to DCI. DCI tries to partition the design into
- What the system is
- What the system does
The first is the domain model and the second is the functionality of the system. Whether "what the system is" is kept in memory, flat files or a DB is important of course but a separate concern and is usually implemented using restricted OO
DCI doesn't really concern itself with persistance.
At http://blog.maxant.co.uk/pebble/files/dci_java_example_for_object_composition_google_group_201010052226.zip I have posted an example in Java, which incorporates JPA (ORM) for persisting entities.
It's part of a white paper to be posted soon at www.maxant.co.uk/whitepapers.jsp
A further example showing DCI being integrated into an app server will be in that paper. Hope that helps!
精彩评论