Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What is the pattern structure of the web adapter

Shulou Source: shulou.com Published: 2022-06-01 03:35:41 10月18日 Update

Today, I would like to share with you the relevant knowledge of web adapter pattern structure. The content is detailed and the logic is clear. I believe most people still know too much about this, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.

motivation

The above class diagram illustrates the object adapter instance. It shows how BoundingBox requests declared in the Shape class are transformed into GetExtent requests defined in the TextView class. Because TextShape matches the interface of TextView to that of Shape, the drawing editor can reuse previously incompatible TextView classes.

This is an example of using existing functionality in the adapter pattern. BoundingBox is a requirement on the side of the graphics editing software, and if you have similar functionality on both the library side, use it. Generally speaking, the parameters and the calling interface will be adjusted as needed. Using the functionality in the ready-to-use library is the purpose of using the adapter pattern.

Adapter is often responsible for providing functions that are not provided by matched classes, and the above class diagram shows how the adapter performs these responsibilities. Because the drawing editor allows users to interactively "drag" each Shape object to a new location, this feature is not available in TextView design. We can add this missing functionality by implementing the CreateManipulator operation of the TextShape class, which returns an instance of the corresponding Manipulator subclass.

Of course, there are also situations where some features are not supported in the existing library. At this point, it needs to be implemented in the adapter. Generally speaking, the part you implement should be relatively easy and have less work, otherwise the effect of using the adapter pattern will be reduced.

Manipulator is an abstract class that describes objects that know how to drive the Shape class to respond to corresponding user input, such as dragging the graph to a new location. Manipulator has different subclasses corresponding to graphics of different shapes; for example, the subclass TextManipulator corresponds to TextShape. TextShape adds functionality that is missing in TextView and required by Shape by returning an instance of TextManipulator.

Generating Manipulator instance is also the need of graphic editing software, the instance of adapter can generate its own Manipulator representation class, and this class can only use the function defined by graphic editing software, or can use the function of existing library.

These are all the contents of the article "what is the structure of the web Adapter pattern?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Tags: Functions adapters adaptations patterns graphics examples knowledge articles different subclasses objects interfaces clarity software facets structures generally speaking side location content Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft NVidia MariaDB Shulou Technology Docker