Potala (4) -- Command pattern

Source: Internet
Author: User

Cnblogs has not been added for a long time. I checked it out yesterday and found it is still betterArticleNot finished. Although not very happy to write, but it is better to do things first and foremost, just write it :)

 

For business logic encapsulation, we use Command pattern in the project. For the reason, the book "Java persistence with hibernate" is quite good. I will not elaborate on it any more, just copy it:

a third tier application may move the presentation layer to a separate virtual machine, the current persistence context can't be held open anymore until the view has been rendered. this is typically the case in three-tiered EJB application, or in an architecture with a rich client in a separate process.
If the presentation layer runs in a different process, you need to minimize the requests between this process and the Tier that runs the business and persistence layers of the application. this means that you can't use the previous lazy approach, where the view is allowed to pull data from the domain model objects as needed. instead, the Business tier must accept responsibility for fetching all data that is needed ubsequently for rendering the view.

Although certain patterns that can minimize remote communication, such as the Session Facade and data transfer object (DTO) patterns, have been widely used in the Java developer community, we want to discuss a slightly different approach. the Command pattern (often also called EJB command) is a sophisticated solution that combines the advantages of other strategies.

For specific interfaces and implementations, you can refer to some of the design patterns books, or you can write for Java persistence with hibernateCodeAdd more methods to the command, and use generics to implement commandhandle.

Another problem is: one operation, one session. in this two-tier system, we can use open session in view (osiv) to solve this problem. There are many solutions for the three-tier system, we used a combination of different commands to solve this problem in one command. The most basic idea was from Java persistence with hibernate. I will not discuss it much.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.