Java Reference
In-Depth Information
8.7 Summary
One drawback of using a POJO façade is that you must write potentially complex
and error-prone code to detach domain objects. A simpler approach, which elimi-
nates the need to detach objects, is to use the Exposed Domain Model pattern.
This pattern keeps the persistence framework connection open for the duration
of the request, which allows the presentation tier to lazily load objects. The pre-
sentation tier calls domain services to update the domain objects, as well as repos-
itories to query the database, and then gets the data to display directly from
domain entities and value objects. You no longer have to worry about detaching
the objects that it needs.
However, while this approach reduces the amount of code that you must write,
there are some tricky design issues because of how transactions, persistence
frameworks, and the servlet API interact. Also, the lack of a façade increases the
chance that changes to the business tier could affect the presentation tier. There
is also the risk of business logic creeping into the presentation tier. Despite these
drawbacks, this approach makes sense for many applications and is becomingly
increasingly popular.
In the next chapter you'll learn how to implement business logic using a pro-
cedural approach.
 
Search WWH ::




Custom Search