Dahua Design Pattern Ten Appearance Patterns

In fact, if you don't know how to trade stocks, buying a good stock and putting it there so-called "enlightened stocks" is the best strategy for stocks.


I heard that the first sentence a psychiatrist asks a patient is, "Are you speculating in stocks?"


The Facade pattern provides a consistent interface for a set of interfaces in a subsystem. This pattern defines a high-level interface that makes the subsystem easier to use.



The appearance pattern perfectly embodies the idea of ​​the Dependency Inversion Principle and the Law of Demeter.



When is Appearance Mode best to use?

First, in the early stages of design, there should be a conscious separation of the two different layers.

For example, in the classic three-tier architecture, it is necessary to consider establishing a facade between the layers of the data access layer and the business logic layer, the business logic layer and the presentation layer, which can provide a simple interface for complex subsystems and make the coupling Greatly reduced.

Secondly, in the development phase, subsystems often become more and more complex due to continuous refactoring and evolution. Adding facades can provide a simple interface and reduce dependencies between them.

Third, when maintaining a first-class large system, it may be very difficult to maintain and expand.

But because it contains very important functions, new requirements development must rely on it. At this time, it is also very appropriate to use the Facade mode.

Develop a facade Facade class for the new system to provide a relatively clear and simple interface to poorly designed or highly complex legacy code, let the new system interact with the Facade object, and the Facade interacts with the legacy code for all the complex work.

For the old system that is complex and difficult to maintain, it may cause many problems to directly modify or expand it. Divide into two groups, one develops the interaction with Facade and the old system, and the other only needs to understand the interface of Facade and directly develop the new system to call these interfaces That's it.



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325473627&siteId=291194637