Re: Repositories, package dependencies, and domain-flavoured exceptions
- From: hansewetz@xxxxxxxxxxx
- Date: 26 Jul 2005 07:15:35 -0700
Jason Che-han Yip wrote:
....
> I have a Repository that will abstract the intricacies of retrieving a
> particular kind of Customer using an Account Number. It is possible
> that the Account associated with the Account Number is closed, or
> doesn't exist, in which case, no Customer should be returned.
....
>
> I had this logic in the Repository, however, we have JDepend (a Java
> package dependency tool) rules preventing references from "domain"
> packages to our "command" packages. The problem was that the Repository
> find method had AccountNotFound and AccountClosed exceptions in its
> signature. The Repository is in the "domain" package, the exceptions
> are in the "command" package.
....
>
> Most of the coordination of domain objects are done in command
> processors which is why, I presume, these domain-flavoured exceptions
> are in the "command" package. There are also Struts (Java
> request-driven web app MVC framework) actions that are used to add
> errors to the view depending on what kind of exception is thrown by the
> execution of the command. I suspect that some kind of generic handler
> could have been used as the exceptions all contain keys to the messages
> that should be displayed. In any case, we have another JDepend rule
> that prevents using "domain" package classes in "action" package
> classes. So I would be inclined to move these domain-flavoured
> exceptions to the "domain" package but this rule prevents me from doing so.
....
If I understand your model you have the following:
-'action' corresponding to access layer (user/service access)
-'command' corresponding to business process layer
-'domain' corresponding to business object layer
If this is correct it makes sense to only allow the following
dependencies:
-'action' can access 'command' can access 'domain'
which corresponds to:
-'access layer' can access 'business process layer'
can access 'business object layer'
In your case the exceptions belongs to the business object layer. This
should not cause a problem since the access layer should only invoke
business functionality through business processes. There should be no
need to access the business object layer directly from the access
layer.
The reason of having processes is to enforce policies for how the
business should be conducted. Business processes are the means a
business uses for achieving its goals. Or put differently, it is the
means a business uses for changing the state of its business objects
into a state that is in correspondence with its goals. If you access
business objects directly from the access layer you bypass this
mechanism.
Regards,
Hans Ewetz
.
- Follow-Ups:
- Re: Repositories, package dependencies, and domain-flavoured exceptions
- From: Jason Che-han Yip
- Re: Repositories, package dependencies, and domain-flavoured exceptions
- References:
- Repositories, package dependencies, and domain-flavoured exceptions
- From: Jason Che-han Yip
- Repositories, package dependencies, and domain-flavoured exceptions
- Prev by Date: Re: Repositories, package dependencies, and domain-flavoured exceptions
- Next by Date: Re: Paralyzed by TDD
- Previous by thread: Re: Repositories, package dependencies, and domain-flavoured exceptions
- Next by thread: Re: Repositories, package dependencies, and domain-flavoured exceptions
- Index(es):
Relevant Pages
|