Re:Changing identifiers
rwallace1979 <rwallace <at> thewallacepack.net>
2008-02-02 21:23:33 GMT
I understand what you mean by having the update() method in the
repository check for uniqueness. That's kind of what I was hoping for.
I'm less clear on what you mean by distinguishing between change the
values in the domain object versus saving the object into the repository.
I mean, in theory I understand what you mean. I'm just not sure
exactly how to implement it in my scenario. Right now, I'm at the
very beginnings of the project and haven't implemented any kind of
persistent backend, so I've just been creating repositories that store
objects in-memory - some collection, like a set or map, depending on
the situation.
So I think part of my problem is that updating a domain object causes
the object in the repository to be changed directly. And the plan is
to eventually move to something like Hibernate, where the persistence
will be transparently done. So there isn't really a _need_ for an
update() method. I could change the behaviour of my in-memory
repository to return a copy of the actual object and create an update
method that has to be called for any changes to be persisted.
Another problem is that I haven't added any surrogate IDs at this
point because I was thinking of them as purely backend issues. Now
I'm starting to think that I'll need a surrogate ID as part of the
domain model so that in the repository I can find any object with the
same natural identifier as the object passed into the update() method
and check to see if the surrogate IDs match. If there is an object
with the same natural identifier and the surrogate IDs are the same,
the the natural identifier isn't changing. If they don't match, then
I can't do the update because an object with the natural identifier
already exists. If there is no object with that same natural
identifier then I can go ahead and perform the update.
Does all this sound reasonable/workable? Is there anything I'm
forgetting?
Thanks for the input, I really appreciate it.
Rich
--- In domaindrivendesign <at> yahoogroups.com, "Bill Hamaker"
<BillHamaker@...> wrote:
>
> I think the normal approach would be to have Update be a method in your
> repository so uniqueness is always checked by the repository. You
> need to distinguish between changing the unique values in the domain
> object versus saving the domain object into the repository.
>
>
>
> If you wanted to check for uniqueness ahead of time I would have a
> CheckForUniqueness methods in the repository also.
>
>
>
> Bill Hamaker
>
>
>
> CONFIDENTIALITY NOTICE:
>
> The information contained in this message may be privileged and
confidential. It may also be protected from disclosure or be a
> privileged work product or proprietary information. This information
is intended for the exclusive use of the addressee(s). If you are not
the intended recipient, please notify the sender immediately by
replying to this message and you are hereby notified that any use,
disclosure,
> dissemination, distribution (other than to the addressee[s]),
copying or taking of any action because of this information is
strictly prohibited.
>
> Thank you,
>
> Marvin F. Poer and Company
>