In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to realize the java facade model". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to realize the java facade model".
Take chestnut 1: the relevant departments that customers will encounter when they go to the local real estate bureau to apply for the transfer of property certificates.
For example, the design of chestnut 2:API gateway, if users want to access the subsystem, it is the access subsystem that is accessed indirectly through the API gateway.
Both of the above designs are facade mode.
Let's look at the UML class diagram in example 1.
Let's look at the code of the three subsystems:
1Universe / subsystem role
2class SubSystem01
3 {
4 public void method1 ()
5 {
6 System.out.println ("method1 () of subsystem 01 is called!")
7}
8}
1Universe / subsystem role
2class SubSystem02
3 {
4 public void method2 ()
5 {
6 System.out.println ("method2 () of subsystem 02 is called!")
7}
8}
1Universe / subsystem role
2class SubSystem03
3 {
4 public void method3 ()
5 {
6 System.out.println ("method3 () of subsystem 03 is called!")
7}
8}
two。 Let's look at the facade code.
1Universe / appearance character
2class Facade
3 {
4 private SubSystem01 obj1=new SubSystem01 ()
5 private SubSystem02 obj2=new SubSystem02 ()
6 private SubSystem03 obj3=new SubSystem03 ()
7 public void method ()
8 {
9 obj1.method1 ()
10 obj2.method2 ()
11 obj3.method3 ()
12}
13}
Application scenario of appearance pattern
You can usually consider using appearance mode in the following cases.
When building a hierarchical system, using the appearance pattern to define the entry point of each layer in the subsystem can simplify the dependency between the subsystems.
When there are many subsystems of a complex system, the appearance pattern can design a simple interface for the system for external access.
When there is a great relationship between the client and multiple subsystems, the introduction of appearance pattern can separate them, thus improving the independence and portability of the subsystem.
Thank you for your reading, the above is the content of "how to realize the java facade mode". After the study of this article, I believe you have a deeper understanding of how to realize the java facade model, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.