Repositories, package dependencies, and domain-flavoured exceptions
- From: Jason Che-han Yip <jcyip@xxxxxxxxxxxxxxxx>
- Date: Tue, 26 Jul 2005 22:53:15 +1000
I figured this group will have some insights so here's my story...
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.
Question #1: Should this logic be part of the Repository?
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.
Question #2: Are Java packages really appropriate to be determining illegal package dependencies? I can accept that this might be a reasonable simplification.
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.
Question #3: Should domain-relevant exceptions like AccountNotFound, AccountClosed be part of "domain" packages? And if so, should presentation packages be able to reference them in order to translate them into view-specific representations?
.
- Follow-Ups:
- Re: Repositories, package dependencies, and domain-flavoured exceptions
- From: paul campbell
- Re: Repositories, package dependencies, and domain-flavoured exceptions
- From: H. S. Lahman
- Re: Repositories, package dependencies, and domain-flavoured exceptions
- From: hansewetz
- Re: Repositories, package dependencies, and domain-flavoured exceptions
- From: Nick Malik [Microsoft]
- Re: Repositories, package dependencies, and domain-flavoured exceptions
- From: iamfractal
- Re: Repositories, package dependencies, and domain-flavoured exceptions
- Prev by Date: Re: OOP/OOD Philosophy
- Next by Date: Re: In search for polymorphism adovacy
- Previous by thread: Template documents
- Next by thread: Re: Repositories, package dependencies, and domain-flavoured exceptions
- Index(es):
Relevant Pages
|