Detailed explanation of an example of realizing the recipe function of the gourmet world based on Java appearance mode

This article describes the implementation of the recipe function of the gourmet world in Java based on appearance mode. Share with you for your reference, as follows:

Model definition

Appearance pattern is a software design pattern commonly used by software engineers. It provides a unified high-level interface for a group of interfaces in the subsystem, which makes the subsystem easier to use. The appearance mode reads / writes the data resources of each interface in the subsystem through one appearance interface, while the customer can read the internal resource library through the appearance interface without interaction with the subsystem.

Two. Example of model

1. Mode analysis

Sweet and Sour Spare Ribs delicacy is the first mock exam to illustrate this pattern.

2. Appearance mode static class diagram

3. Code example

3.1 create an ispareribs interface for sweet and sour ribs

3.2 sweet and sour spareribs

3.3 create appearance interface icookfacade

3.4 appearance realization - cookfacade

3.5 client test

4. Operation results

3、 Design principle of this mode

1. Demeter's law - the principle of minimum knowledge

2 package change part

The diagram further shows the relationship among client applications, appearance patterns and complex applications within the subsystem

4、 Use occasion

1. The complexity of a software system is relatively high, and a higher-level simple interface is required to simplify the operation of the subsystem.

2. When there are too many dependencies between the user and the implementation class, it is necessary to reduce the coupling between the user and the subsystem or subsystem and increase the independence of the subsystem.

3. Appearance mode can be used when subsystems are interdependent and need to be hierarchical to simplify the dependencies between subsystems.

5、 Appearance mode static class diagram

For more information about Java algorithms, readers who are interested can see the topics on this site: Java data structure and algorithm tutorial, summary of Java DOM node operation skills, summary of java file and directory operation skills, and summary of Java cache operation skills

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>