Re: Repositories, package dependencies, and domain-flavoured exceptions



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

.



Relevant Pages

  • Runtime PropertyGrid and custom UITypeEditor with Business object
    ... I am implementing a propertygrid on a form that is "bound" to a business ... I can't put the UIEditor code in the business object layer as that would ... I can't put the UIEditor code in the Winform UI layer assembly because I ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: FreeMoneyFromPaypal?
    ... I have a more economical business for all of you, it will cost you less than ... Since all it takes is a simple "service" to be performed for money transfers ... ACCOUNT I ... HOW TO POST TO NEWSGROUPS & MESSAGE BOARDS ...
    (comp.cad.solidworks)
  • Re: Life Sucks, Then You Move On
    ... with their existing customers. ... A business card with some of the things ... Mine is a plain white card with the company name in red ... few days later the money for all 11 months was back in my account. ...
    (alt.security.alarms)
  • samples of philipppine descriminatroy hiring practices . their own word s by adds
    ... service management needs aggressive and self-motivated individuals to ... - Female, between 21-30 years old, single ... - Business course graduate, preferably Accounting ... Account Manager - at least 3 years experience ...
    (soc.culture.filipino)
  • Re: samples of philipppine descriminatroy hiring practices . their own word s by adds
    ... service management needs aggressive and self-motivated individuals to ... - Female, between 21-30 years old, single ... - Business course graduate, preferably Accounting ... Account Manager - at least 3 years experience ...
    (soc.culture.filipino)