Jay Walters wrote:
> I'm just looking at the latest petstore (1.1.2) and seeing that they use the
> structure of a separate model object within each entity bean to hold the
> persistent attributes. They provide a method getDetails() which will return
> this object to a client.
We do something similar and still have been able to keep the client code
uncoupled from the data structures. We accomplish this in two ways. One is to
not send the entity bean's detail data object directly to the presentation
layer. Instead, have the session bean facade handle repackaging the data in a
task (use case) appropriate data structure. The other is to build into the
presentation layer an object I'll call an adapter for lack of a better pattern.
This object will take requests for specific data elements from the UI and
retrieve that element from the data provided by the enterprise bean(s). Both of
these approaches has it's own problems, but we have successfully used a
combination of both.
> This seems to be the anti-pattern to facade, build
> a facade and then expose the data structures behind the facade to the client
> directly.
That depends on what you mean by "client". The client of the entity bean will be
exposed to the data structures. What's the difference between that and having
the entity bean's client exposed to the entity beans API? If you want to be able
to change data members of the detail object without effecting the "client" then
give this detail object a well defined API and make the data members private.
> It directly couples the client to the structure of the database.
Hardly. The detail object doesn't have to mirror the database schema.
>
> I know the big argument is that it saves a few lines of code, but it seems
> like a Faustian bargain. Does this rub anybody else the wrong way?
No. But then we've been using this approach for 3 years.
--Victor Langelo
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".