Here are four design patterns: Appearance (Fa?ade: Provides a consistent interface for a set of function calls in a subsystem that makes the subsystem easier to use; Decoration (decorate): When the method of generating subclasses cannot be expanded, Dynamically add some extra functionality to an object; single-piece (Singleton: guarantees that a class has only one instance and provides a global access point to access it; Template method: A framework that defines an algorithm in a method, and some of the steps in the algorithm are deferred to a subclass. Choose the appropriate design pattern according to the scenario described below. If some classes in an object-oriented system have and have only one instance, the adoption of (30 design mode can effectively achieve this purpose; a submodule in the system needs to provide other modules with access to different database systems (Oracle, SQL Server, DB2 UDB, etc.). These database systems provide a certain difference in the access interface, but the access process is the same, for example, to connect to the database, then open the database, and finally query the data, (31 design patterns can abstract the same database access process , the text display class in the system (TextView and the Picture display class (Pictureview inherit the component Class (Component, which displays both text and picture content, and now needs to be constructed with scroll bars, or with a black border, or a text display control and a picture display control that has both a scroll bar and a black border, but you want to add up to only three classes, (32 design mode can do that.)
(30A. Appearance B. Decoration c. single piece D. Template method
(31A. Appearance B. Decoration c. single piece D. Template method
(32A. Appearance B. Decoration c. single piece D. Template method
31C
32D
33B
The following shows the effect of four design patterns: Appearance (F