Re: Repositories, package dependencies, and domain-flavoured exceptions
- From: hansewetz@xxxxxxxxxxx
- Date: 27 Jul 2005 03:34:49 -0700
Jason Che-han Yip wrote:
> hansewetz@xxxxxxxxxxx wrote:
>
> ...
>
> > 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.
>
> ...
>
> In this particular case, the "access layer" needs to be able to access
> the exceptions in order to determine how to present them. How would you
> propose to resolve that, given enforced dependency restrictions (access
> -> business process -> business object) and placing domain-flavoured
> exceptions in the business object layer?
The process layer must know how to interpret failures. Different
processes may interpret 'failures' differently. In short, the
process layer will map your exceptions to something that makes sense in
the context in which the process is running.
Notice that I only addressed issues related to dependencies in your
project. I did not address issues related to the correctness of
throwing exceptions or not.
I would suggest that you also take a look at Mr. Lahman's email. He
points out, more eloquently than I can, that the context of a client
determines the semantics of 'failures'.
I would also take a look at failure and error management in general.
It's important to distinguish between normal processing logic,
technical failures and bugs in business rules. It is also important to
map the different types of problems into technical constructs in a
consistent way.
It seems questionable if it is appropriate to throw an exception in
case an Account is not found. If the application is mission critical
and the Account MUST exists it may be the case that the application
should be terminated. The reason is that if the account MUST exist and
you fail to look it up, your system is in an inconsistent state.
If a failure to look up an Account is normal predicted behavior, it is
probably a bad idea to throw an exception. One of the few cases where I
can see exception as a way to handle predicted behavior is management
of optimistic locking failure in transactional applications.
Regards,
Hans Ewetz
.
- References:
- Repositories, package dependencies, and domain-flavoured exceptions
- From: Jason Che-han Yip
- Re: Repositories, package dependencies, and domain-flavoured exceptions
- From: hansewetz
- Re: 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: OO Design induces an existential crisis
- 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
|