The structural design pattern solves the coupling problem between the modules from the structure of the program. The following seven modes are included:
Adapter mode: An excuse for the class can be matched to another interface
Combination mode: The combination of objects
Proxy mode: A Simple object instead of a complex object that will be called later
Appearance Mode: A class represe
Overview of structural Design PatternsA structured design pattern is used to handle a combination of classes or objects that describe how classes and objects are organized together to form large structures that enable new functionality.Mechanism of implementation:The structured object pattern uses a combination/aggregation mechanism to combine classes, including
Graitec OMD 1DVD French structural designThe French structural design program that can be perfectly combined with AUTOCAD to meet the requirements of most engineersDriveworks Pro V12 SP0 for SolidWorks 2010-2015 win32_64 1CDExelis ENVI v5.3, IDL v8.5, LiDAR v5.3 1DVDGraitec OMD 1DVDAutodesk.Stingray.v2016 1DVDClearterra locatext ArcGIS for Server Tool 1.2 win32_6
A structured pattern describes how classes and objects are organized to form larger structures. The structure type class pattern uses the inheritance mechanism to combine the interface and the realization, the structural object pattern uses the combination aggregation to combine the object to realize the new function, may change the object composition relation in the operation time, has the more flexibility, therefore only concerns the
. Protection (Protect or access) Proxy: Controls access to an object and, if necessary, provides different levels of usage rights to different users. The benefit of the protection agent is that it can check the user's permissions at run time and then decide to pass the call to the Proxied object after verification.5. Cache Proxy: Provides temporary storage space for the results of a target operation so that multiple clients can share the results.6. Firewall (Firewall) Proxy: Protects the target
void Sellcar ();its implementation classpublic class Hongqicompany implements Companyimplementor {@Overridepublic void Producecar () {System.out.println ("Production car" );} @Overridepublic void Sellcar () {System.out.println ("car Sold");}}Advantages of bridge mode1. Abstraction and implementation separation: it is a design pattern that is designed to address the drawbacks of integration. In this mode, the implementation can be unconstrained by the
Design pattern (ix) Appearance mode facade (structural type)1. Overview
Appearance mode, we use the appearance of packaging, so that the application can only see the appearance of objects, but not to see the details of the object, this will undoubtedly reduce the complexity of the application, and improve the maintainability of the program.Example 1: A power master switch can control four lights, a
Bridging mode is a structural design pattern.Design Intent: separate the abstractions from the implementation, so that they can be changed independently .When you see the design intent, you may be a little confused, we see that the inheritance and interface are not both abstract and implementation of separation? In particular, interfaces and abstract classes are
First, IntroductionToday we are going to talk about the second mode of "structural" design pattern, which is "bridge mode", also called "Bridge mode". What do you think the first time you see this name? The first time I saw this pattern, I guess it was connected to something by name. Because the bridge in our real life is often connected to a and B, and then to the later development, Bridge extension as a l
Learning the creation mode gradually understands the advantages of interface-Oriented Programming and implements the principle of dependency abstraction. Learning the structure mode shows the benefits of using object combinations. Compared with inheritance, it brings many advantages, especially in the bridge and decorator modes. In fact, the structural model can be seen everywhere in the project, and is used unconsciously in the previous project. Alth
Definition:The Flyweight Pattern uses the sharing technology to effectively support a large number of fine-grained objects.
Type: structural mode.
Applicability:
An application has a large number of objects.
Most States of objects are external.
If you delete the external state of an object, you can replace many groups of objects with a relatively small number of shared objects.
Applications do not rely on object identifiers, that is, application
PS One sentence: Eventually choose Csdn to organize the publication of the knowledge points of these years, the article parallel migration to CSDN. Because CSDN also support markdown grammar, Ah!"Craftsman Joshui Http://blog.csdn.net/yanbober" read the previous article, "Design pattern (structural type) of the decorator mode (Decorator pattern)" http://blog.csdn.net/yanbober/ article/details/45395747Overvie
of dynamically expanding object function at run time, and can extend multiple functions according to need, avoids the "flexibility difference" and "multi-subclass derivation problem" which is caused by using inheritance alone. At the same time, it conforms well to the principle of object-oriented design, which is "preferential use of object combination rather than inheritance" and "open-closed".ResourcesShanhong, Java and patterns, electronic industr
(new User ())); }}(Implementing permission checks is the same.) )the difference between a dynamic agent and a static proxy:The above implementation is called static proxy, the agent can only proxy Userdaoimpl class, but similar to the spring framework is not possible to add static proxy for each class (which will cause the explosion of the class), so there is the concept of dynamic agent proxy, By passing the Proxied class into the proxy class, we can return a Proxied object, and the business
PS One sentence: Eventually choose Csdn to organize the publication of the knowledge points of these years, the article parallel migration to CSDN. Because CSDN also support markdown grammar, Ah!"Craftsman Joshui Http://blog.csdn.net/yanbober" read the previous "bridge pattern" of design mode (structural type) http://blog.csdn.net/yanbober/article/ details/45366781OverviewThe combination pattern, also calle
, log management, and more.additionalStruts2 's Interceptor is an AOP idea, using proxy modeIn Struts2, One of the most important classes is when a Org.apache.struts2.dispatcher.FilterDispatcher user submits a httpservletrequest request through a browser, the request is intercepted by a filter filterdispatcher in Web. xml The Filterdispatcher filter first asks if Actionmapper needs to invoke an action to process the request, and if Actionmapper decides that a request needs to be invoked, Filterd
Bridge)The bridge mode is used to solve the problem of multi-dimensional changes of the system. It separates the abstract part from the implementation part so that they can all change independently. (See the understanding of the Bridge Mode)Structure:Examples in life:
Composite)
Intent:Combine objects into a tree structure to represent the "part-whole" hierarchy. The composite mode ensures consistency between the use of a single object and a composite object. [Gof
Article 1: Creation Mode of Design Mode
In this section, we focus on the structure mode in gof, which is mainly used to describe how to combine classes to form a larger structure. Structural modes include adapter, decorator, bridge, flyweight, facade, composite, and proxy modes.
Next we will describe the modes mentioned above separately.
1)Adapter). When we have developed a module with a clear set of int
Design Pattern (11) Decorator pattern-Structural PatternDecorator Mode
In program development, developers sometimes use inheritance to extend the functions of objects. The user's requirements are changeable, which leads to wide-range changes to the Code when inheritance is used, in fact, the extended object function is much better than inheritance by using a combination. When users need to change the object
the user's database. * Appearance mode the largest feature wraps fine-grained objects into coarse-grained objects, and the application accesses this skin object to complete the invocation of fine-grained objects. * We use the appearance of packaging, so that the application can only see the appearance of objects, but not to see the details of the object, this will undoubtedly reduce the complexity of the application and improve the maintainability of the program * @author Tong * */public class
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.