The following shows the effect of four design patterns: Appearance (F

Source: Internet
Author: User

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

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.