D
dan
I've seen lots of postings around this issue, however I may need some
more info especially with the limitations that my project introduces.
I'm in the process of designing the presentation layer of my web-based
network management application. My concern is regarding the way the
business layer objects should (or maybe they shouldn't at all??) be
exposed to the presentation. Why exposing business objects to the
presentation may be problematic? At least in my case the business
objects represent a live pool of related objects - network entities, a
hierarchy that gets constructed and modified periodically from the
persistency regardless of the presentation requests. That is, the
objects are there because they are part of some use cases that may not
involve the presentation layer. In addition the Business class
hierarchy is of course not built for a specific presentation and some
of the business layer logic is intrinsic to the business layer itself.
For example, some of the flows are only known to the Business layer
and not to the presentation layer, some of the presentation uses are
delegated to other business objects that perform some action and
return data to the presentation, and some of the presentation objects
are sort of combinations of business objects.
I may be wrong here but as I see it providing a common interface to
the business objects for both business and presentation is wrong since
it will result in endless methods for each object. Providing a common
data part for each business object that will be used by presentation
and business will violate the encapsulation policy of the business
objects since presentation would be familiar with the internal state
or implementation of the business objects. However creating a
presentation layer representation for every object in the business
layer also seems a bit cumbersome...
So the question is how should the business layer objects be exposed or
transfered to the presentation layer. I believe that this problem is
widely addressed by many projects - in fact I can't imagine any tiered
project that doesn't introduce this kind of concerns. However I
couldn't find any design pattern that perfectly addresses this
problem. I was wondering if the Builder pattern or the AbstactFactory
pattern may fit here but being unexperienced with those I'm not sure.
Your help is greatly appreciated
TIA,
DK
Thank you all for the detailed and helpful answers!
DK