Domain-Driven Design
> >
PersistenceAndLayers

Tue Nov 6, 2001 4:43 am

Nick (NickRobinson) wrote:

> It is clear JDO brings a lot to the table, and the domain
> objects remain as pure domain objects
> and (not being a Java guy this is guessing) the persistence
> stuff would sit in an upper layer
> (application/controller)?

Randy commented:

> Actually a lower layer, namely the persistence layer, as I wrote in
Chapter
> 7 of EJB Design Patterns (John Wiley & Sons, 2001).

I visualise things in terms of a Domain Layer which sits on top of a
Persistence Layer, but does not invoke it directly. Domain objects interact
with other domain objects. Persistence happens under the covers.
Application objects which are not themselves persistent are responsible for
Finding domain objects (via non-persistent Repository classes or a query
language) and for transaction demarcation (perhaps delegated to a container
as in CMT), and for the direct invocation of persistence services to make an
object( and its reachable objects) persistent, etc.

Separately, Randy wrote:

> In the Service Layer chapter I contributed to Martin Fowler's Patterns of
> Enterprise Application Architecture, I tried to draw a distinction between
> "application" logic and "domain" logic. It just seems to me that there is
> often logic required in an application that is not "of" the problem
domain,
> but rather "of" the application itself. For example, <snip>

I agree. Domain objects talk to other (persistent) domain objects. When a
domain object starts invoking infrastructure services such as messaging, I
begin to get uncomfortable. It prevents the domain objects from being
tested in isolation from those external services. Such logic I usually put
into a service tier. But that does not imply the service tier should be
thick. Many methods in a service object merely turn around and invoke same-
or similarly-named methods on a domain object. The service objects bring
the container-provided services (transactions, remoteness, asynchronicity)
to bear, but most logic remains in the domain objects themselves and how
they manage and exploit their collaborations with other domain objects.

Thanks for the chapter extract, Randy. I will add it to my TODO list.

Kind regards
RobinRoos




PersistenceAndLayers is mentioned on: ThreadView


VeryQuickWiki Version 2.6.3 - HTML Export