[TYPO3-50-general] FLOW3 and DDD
Nino Martincevic
don at zampano.com
Mon Jan 19 11:51:51 CET 2009
Hi Robert,
Robert Lemke schrieb:
> Yes, sure, but technically you can annotate a class as @entity, create
> an instance of it and don't add it to a repository or an entity which
> is part of an aggregate. Then it won't be persisted.
>
> So conceptually a class annotated as @entity is always a member of an
> aggregate. But it doesn't mean that it will be persisted (that's only
> the case if it has a connectino to a repository).
Hm, that seems to be a conceptual problem, though I'm not aware of the
whole current architecture and the next statement shows me that you have
probably already thought of it.
You said:
"Therefore if you create an entity or value object, it will only be
persisted if it is connected to an aggregate (an thus a repository)."
That's exactly the point.
I guess we agree that an entity is always part of an aggregate.
As you stated right (and a bit extended here) the only way to access an
entity in DDD is through an aggregate (root) and an aggregate is only
accessible through a repository.
So, there can't be any entity instance not "directed" (created or saved)
by a repository. You simply cannot create an entity that belongs to an
(complex) aggregate from outside without going through the root and
therefore having a "connection", i.e. it has always a "connection" to
the repository.
<Excursion>
Well actually not in DDD sense but in the current infrastructure and
technical solution of Flow3. Because some DDD guys even don't do that
with repositories, just maintaining the lifetime of living entities,
keeping it completely peristance ignoring. A domain model should be that
for being "perfect" but we also have to face the facts. And they are
that there will be some persistence at some point.
But I'm with you regarding this issue, my repositories also "save"...
</Excursion>
On the other side perhaps you don't need to change anything. Because if
someone wants to create an non-root entity bypassing the repository and
aggregate he may do so for whatever reasons. But if he wants that entity
to be persisted he has to add it to a aggregate/repository and he has to
do it with the provided methods of the aggregate root.
Perhaps you could use an @aggregate annotation (if you don't have it
already). That way you could avoid non-root entities to be created
outside an aggregate, at least conceptually.
Maybe this thoughts could help to refactor the current implementation?
But like I already said: I don't want to impute that you haven't just
thought of it...
:-)
>> And actually you don't and can't have a repository for value objects,
>> because they have no identity. How a repository would find them then?
> Sure, but I didn't say that, did I?
Well, don't know exactly ;-)
Perhaps I read this statement in the above citation...
Nino
More information about the TYPO3-project-5_0-general
mailing list