Enforcing domain rules



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

.



Relevant Pages

  • Re: Password Policy for remote users
    ... Setting the "password never expires" flag will stop the password from ... to enforce multiple policies and assign them to users, groups, and OUs. ... accounts, and this or the highest priority GPO setting account policies ...
    (microsoft.public.security)
  • Re: GPO not picking up computer settings
    ... That the Account Policies are computer policies means that they ... Results and Group Policy Modeling does it tell me that the effective ... I see that it has inherrited the settings from the new GP I have created. ... then how do I enforce it only ...
    (microsoft.public.windows.server.security)
  • RE: Cant change power settings
    ... I have not tried to change the registry, I do not know how and besides, ... Your account is limited ... You can't enforce ... Managing Power Options as a non-administrator ...
    (microsoft.public.windowsxp.general)
  • Re: PayPal is eBays Deputy in Policing Morality??
    ... Is PP really going to be allowed to simply enforce whatever policies they fit to enforce... ... Even though PP terminated my account for using their services, people still email me all the time asking if I'll accept PP for X rated video. ... If everyone stopped using PP for all the things that are against their policy, I'm sure they'd soon realize how much they're losing and change their policy ... ...
    (alt.marketing.online.ebay)