- Java EE 8 Design Patterns and Best Practices
- Rhuan Rocha Jo?o Purifica??o
- 398字
- 2021-07-23 16:54:57
Explaining the Session Fa?ade pattern
Before we introduce the Session Fa?ade pattern, it is important to cover the fa?ade patterns, which are one of the structural design patterns mentioned in the Gang of Four (GoF) book.
The main goal is to encapsulate the complexity of business logic in a business interface. Broadly speaking, this interface only exposes a small number of coarse-grained methods to the client. Each of these interface methods is responsible for controlling the underlying complexity of business logic. In this way, the internal services of finer granularity can be combined into a set of services that are exposed by the interface method.
The benefits of using a fa?ade pattern are as follows:
- It provides coarse‐grained methods for available services.
- It reduces remote calls. A remote client does not need to call many fine-grained business objects. Instead, it executes a remote call to the exposed interface method, which is responsible for making local calls to the fine-grained objects.
- It can create a single channel to a legacy backend system.
- It decreases the coupling between the client and the fine‐grained objects.
Let's say, for example, that there is a system for checking vacancies in hotels in a city. The hotels offer web services to be consulted about the vacancies. A client application that wants to know how many vacancies are available will have to make a call to each web service. But if we make a call to a fa?ade layer, this fa?ade could take responsibility for searching the web services. In addition to reducing calls, the fa?ade removes the high coupling that would exist between the client and web services.
By understanding the problem for which the GoF fa?ade pattern is the solution, we can then see a similar problem with JEE. In this case, server-side components are implemented as Business Objects (BOs) or POJOs. Almost every request coming from the client needs a BO interaction, and each BO involved in the request process may have a relationship with other BOs. In addition, the BO might have accessed an integration tier using a DAO pattern. We do not want to expose the complexity of the business components and their internal relationships to clients—especially to remote clients. We then have a Session Fa?ade pattern as a solution to this problem.
- 電腦組裝與系統(tǒng)安裝
- Linux設(shè)備驅(qū)動開發(fā)詳解:基于最新的Linux4.0內(nèi)核
- Linux Mint Essentials
- Extending Puppet
- 構(gòu)建可擴展分布式系統(tǒng):方法與實踐
- Linux網(wǎng)絡(luò)內(nèi)核分析與開發(fā)
- 8051軟核處理器設(shè)計實戰(zhàn)
- Windows Server 2012網(wǎng)絡(luò)操作系統(tǒng)項目教程(第4版)
- Windows 8實戰(zhàn)從入門到精通(超值版)
- VMware Horizon View Essentials
- Kali Linux高級滲透測試(原書第3版)
- Troubleshooting Docker
- Hadoop Real-World Solutions Cookbook
- VMware Horizon Mirage Essentials
- Linux內(nèi)核修煉之道