Web accumulation: Facade and webfacade

Source: Internet
Author: User

Web accumulation: Facade and webfacade
Web accumulation: appearance mode Facade Abstract: Original Source: http://www.cnblogs.com/Alandre/ Sediment Brick pulp carpenter hope to reprint, retain abstract, thank you! Preface

I haven't written an article for a long time in visual testing, and it is more than 20 days away from the previous article. What happened to me? Haha ~, Two words: life. Life seems to be too big, so be healthy. Have a good time and wisdom

Thinking about life-to-life

My faith? Buddhism? Christ ?... When you are ill, take medicine. For example, if you have a cold or cold medicine, you will find it hard to take it. People are like that, But when you think of it, you are helpless when you are ill and have no medicine to eat. For example, my chest tightness and chest pain. It is followed by the ups and downs, Shanghai-Wenzhou-home Taizhou, run everywhere. Seeing a doctor, what? No disease? No

At that time, I was afraid of traveling, and I was powerless. It's just a matter of attention, and my mind is gone. Check the code? I forgot what I thought when I looked at java.

 

But the doctor did not take the medicine, and he was decadent... That is, the beginning of the school year. I took a scared bullet train to school again. I believe that I will be able to stay up late and rest regularly. The first week is the longest day, the inability to listen to the class, and the waist hurts. Shit! Stick... Stick... Later, it became obvious that it was quite powerful. In the second week, I started to exercise. Currently, I have been exercising for six days. Fuck my heath! I am coming, hope no so late.

 

Ii. Contact of appearance Mode

Looking at the source code is a kind of enjoyment. It's okay. You have to worry about it. I think you should study. Haha ~ The first time I saw it was here:

 

In this case, knowing is what you use is true. I went to Baidu to get this Facade right away. I know it's a pattern. That's right. Learn it. After talking about it, I checked the video and blogs. Why not read it.

 

Facade can encapsulate a series of complex packages into a simple closed interface. It can also be said that the external communication between a sub-system and its internal systems must be performed through a unified Facade object. Communication means interaction. It provides a high-level interface for ease of use.

 

Structure of appearance Mode

Facade defines a simple call interface for the caller.
Clients caller. Internal group that provides a function by calling the Facade interface.
Packages function provider. Groups (modules or subsystems) that provide functions)

Small appearance mode example

In reality, when there were no funds in 80 or 90 s. Treasury bonds, stocks, futures... They all run separately. For example:

Stock:

123456 public class Gupiao {               public void mai() {           System.out.println("Buy stock");      }  

Futures:

123456 public class Qihuo {               public void chao() {           System.out.println("Buy futures");      }  

National debt:

123456 public class GuoZai {               public void mai() {           System.out.println("Buy government bonds");      }  

If you want to buy government bonds and futures, you will deal with your systems. New. So this will cause the following points:

1. Increased Coupling

2. non-hierarchical structure

 

Since having funds. What is a fund, according to the appearance model, is that you do not know how many kinds of stocks or what, the Fund helps you manage these small systems. It helps you arrange various solutions, such

Fund:

12345678910111213141516171819202122 public class JiJin {       private Gupiao gupiao;       private GuoZai guozai;       private Qihuo qihuo;               public JiJin() {           this.guozai = new GuoZai();          this.gupiao = new Gupiao();          this.qihuo = new Qihuo();      }              public void maiJijinA() {           this.guozai.mai();          this.gupiao.mai();      }              public void maiJijinB() {           this.guozai.mai();          this.gupiao.mai();          this.qihuo.chao();      }  

Test Case:

123456 public class MainClass {       public static void main(String[] args) {           JiJin jijin = new JiJin();          jijin.maiJijinB();      }  

In this way, its practicality will come out:

1. provides a simple interface for a complex subsystem.

2. Improve the independence of subsystems.

3. In a hierarchical structure, you can use the Facade mode to define the entries for each layer of the system.

 

Wu thinks in the Web

 

1. The three-tier web architecture is used to establish an external Facade application between the data access layer and the business logic layer, the business logic layer, and the presentation layer and layer, provides a simple interface or abstract class for a complex subsystem, greatly reducing coupling.

2. In the development stage, subsystems tend to become more and more complex due to constant reconstruction and evolution. Many small classes will be generated in most modes. This is a good thing, however, it also makes it difficult to use the user programs that call them externally. by increasing the appearance, Facade can provide a simple interface to reduce the dependencies between them.

Specific practice: plan and classify small categories. Then implement the proxy Facade.

3 when maintaining a legacy large system, it may be very difficult to maintain and expand, but because it contains very important functions, new demand development must depend on it. In this case, Facade in appearance mode is also very suitable. For example, you can develop a Facade class to provide clear and simple interfaces for designing rough or highly complex legacy code, so that the new system can interact with the Facade object, facade interacts with legacy code for all complex tasks.

Lu thanked the knowledge sources and summary

It can be widely used in WEB and project architecture. Come on !!

References:

Google articles and your own experiences.

If the above article or link is helpful to you, don't forget to click "like" in the article button or in the lower right corner of the page. You can also click the "share" floating button on the right side of the page to let more people read this article.


Java 23 design modes

There are three types of design patterns: creation, structure, and behavior.
The creation types include:
I. Singleton, Singleton mode: ensure that a class has only one instance and provide a global access point to it.
2. Abstract Factory: provides an interface for creating a series of related or mutually dependent objects without specifying their specific classes.
3. Factory Method: Define an interface used to create objects, and let the subclass decide which class to instantiate. Factory Method delays the instantiation of a class to the subclass.
4. Builder: separates the construction of a complex object from its representation, so that different representations can be created during the same construction process.
5. Prototype: Use a Prototype instance to specify the type of the object to be created, and copy the Prototype to create a new object.
Behavior types:
6. Iterator: provides a method to access each element of an aggregate object sequentially without exposing the internal representation of the object.
7. Observer: Observer mode: defines one-to-many dependencies between objects. When the status of an object changes, all objects dependent on it will be automatically updated by notification.
8. Template Method: defines the skeleton of an algorithm in an operation, and delays some steps to the subclass, templateMethod allows the subclass to redefine a specific step without changing the structure of an algorithm.
9. Command: encapsulate a request as an object so that you can parameterize the customer with different requests, queue requests and record request logs, and supports unrecoverable operations.
10. State: allows an object to change its behavior when its internal State changes. The object seems to have changed its class.
11. Strategy: Define a series of algorithms, encapsulate them one by one, and enable them to replace each other. This mode allows algorithms to be independent of customers who use them.
12. China of Responsibility, Responsibility chain mode: Enables multiple objects to process requests to avoid coupling between the request sender and receiver.
13. Mediator: uses an intermediary object to encapsulate object interaction of some columns.
14. Visitor, Visitor mode: indicates an operation that acts on each element in an object structure. It allows you to define new operations that act on this element without changing the element classes.
15th, Interpreter, Interpreter mode: a language is defined to define a representation of its grammar and an Interpreter. This Interpreter uses this representation to explain sentences in the language.
16. Memento: capture the internal state of an object without interrupting the object, and save the state outside the object.
There are:
17. Composite: Composite combines objects into a tree structure to represent the relationship between parts of the whole. Composite makes the use of a single object and a Composite object consistent.
18. Facade, appearance mode: provides a consistent interface for a group of interfaces in the subsystem. fa? Ade provides a high-level interface, which makes the subsystem easier to use.
19. Proxy: provides a Proxy for other objects to control access to this object.
20. Adapter: the Adapter mode converts a class of interfaces into another interface that the customer wants. The Adapter mode makes those classes unable to work together due to interface incompatibility.
21. Decrator: the Decorator mode dynamically adds some additional responsibilities to an object. In terms of the added functions, the Decorator mode is more flexible than the subclass generation mode.
22. Bridge: link the abstract Part with its implementation... the remaining full text>

What are the java modes?

There are three types of design patterns: creation, structure, and behavior.
The creation types include:
I. Singleton, Singleton mode: ensure that a class has only one instance and provide a global access point to it.
2. Abstract Factory: provides an interface for creating a series of related or mutually dependent objects without specifying their specific classes.
3. Factory Method: Define an interface used to create objects, and let the subclass decide which class to instantiate. Factory Method delays the instantiation of a class to the subclass.
4. Builder: separates the construction of a complex object from its representation, so that different representations can be created during the same construction process.
5. Prototype: Use a Prototype instance to specify the type of the object to be created, and copy the Prototype to create a new object.
Behavior types:
6. Iterator: provides a method to access each element of an aggregate object sequentially without exposing the internal representation of the object.
7. Observer: Observer mode: defines one-to-many dependencies between objects. When the status of an object changes, all objects dependent on it will be automatically updated by notification.
8. Template Method: defines the skeleton of an algorithm in an operation, and delays some steps to the subclass, templateMethod allows the subclass to redefine a specific step without changing the structure of an algorithm.
9. Command: encapsulate a request as an object so that you can parameterize the customer with different requests, queue requests and record request logs, and supports unrecoverable operations.
10. State: allows an object to change its behavior when its internal State changes. The object seems to have changed its class.
11. Strategy: Define a series of algorithms, encapsulate them one by one, and enable them to replace each other. This mode allows algorithms to be independent of customers who use them.
12. China of Responsibility, Responsibility chain mode: Enables multiple objects to process requests to avoid coupling between the request sender and receiver.
13. Mediator: uses an intermediary object to encapsulate object interaction of some columns.
14. Visitor, Visitor mode: indicates an operation that acts on each element in an object structure. It allows you to define new operations that act on this element without changing the element classes.
15th, Interpreter, Interpreter mode: a language is defined to define a representation of its grammar and an Interpreter. This Interpreter uses this representation to explain sentences in the language.
16. Memento: capture the internal state of an object without interrupting the object, and save the state outside the object.
There are:
17. Composite: Composite combines objects into a tree structure to represent the relationship between parts of the whole. Composite makes the use of a single object and a Composite object consistent.
18. Facade, appearance mode: provides a consistent interface for a group of interfaces in the subsystem. fa? Ade provides a high-level interface, which makes the subsystem easier to use.
19. Proxy: provides a Proxy for other objects to control access to this object.
20. Adapter: the Adapter mode converts a class of interfaces into another interface that the customer wants. The Adapter mode makes those classes unable to work together due to interface incompatibility.
21. Decrator: the Decorator mode dynamically adds some additional responsibilities to an object. In terms of the added functions, the Decorator mode is more flexible than the subclass generation mode.
22. Bridge: link the abstract Part with its implementation... the remaining full text>

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.