Enforcing domain rules
- From: "Mikeon" <mikeon@xxxxxxxxx>
- Date: 3 Feb 2007 09:07:17 -0800
Suppose there is a system where you can create accounts. After
creation account is added to a repostory.
I want to ensure that there are no duplicates so I create a
specfication DuplicateAccountSpecification which I can use to check if
account is a duplicate of an existing account.
Where should I put the logic to make this verification?
sample architecture
UI
----
Services
----
Model
----
Infrastructure
In Services layer I have a method to create account. That method
creates account object, adds it to repository and commits changes.
Now I can enforce uniquness on the infrastrcture level, but that will
result in some bad exceptions.
I can enfocre the check using DuplicateAccountSpecification on
Services layer by checking for duplicates before adding new account
to repository. That will result in domain not enforcing this rule
which means that it may be possible to bypass it.
Finally I can enforce this rule in the model code, but how. And by how
I mean a generic way, that lets me add, remove rules. I have few
ideas, but none of them seam very clean.
I could make DuplicateAccountSpecification depend on AccountRepository
and call the right methods there for example.
I could make a generic - before commit check feature - on repository
that verifies the collection of constraints before commiting.
Any ideas?
--
Michal
.
- Follow-Ups:
- Re: Enforcing domain rules
- From: H. S. Lahman
- Re: Enforcing domain rules
- Prev by Date: Re: Client/Service relationships & Flow of Requirements.
- Next by Date: Re: Client/Service relationships & Flow of Requirements.
- Previous by thread: SETP-07 call for papers
- Next by thread: Re: Enforcing domain rules
- Index(es):
Relevant Pages
|