Insight into the nature of | the middle on the power of software designed to add a layer

Why write this topic?

Add a layer of software design center solutions everywhere. The purpose of this writing is because see a lot of scenes are based on the application of this idea to think of comb, so that we see the contents of some essential.

The way to some of today's mainstream technology or concept as a sample, dismantling, assist you understand.

Find out the underlying logic and design ideas, it will not be all kinds of technical terms, the technical concept of the whole look of ignorant force.

Now three high avalanche of explanations, training, do school work too hard, do the whole body three high, ha ha, a joke.

But the level of design software, something to think programming, we also need to enhance learning, thinking precipitation. Techniques are not only three high.

And the level of thinking of things like learning a specific technical framework, threw himself into a few days or even a few hours can use to get started. But rather accumulated bit by bit, bit by bit, thinking summarized.

See summary of others does not work, others will always be someone else's, reference may be, we must summarize their own.

Return to the theme, today's share is "on the middle layer of software designed to increase the power."

Start of Text

Are you familiar with the jvm

We have to look at a simple executes jvm.

jvm.png The figure is a simplified jvm part is not strict, focus on the overall structure, you can see, JVM in between class file and operating systems. JVM done to achieve for different operating systems. JVM different platforms will be interpreted as a class corresponding platform machine code execution.

After adding JVM, occurs between the class by the operating system after the new operating system, only need to implement a JVM for the corresponding platform (JVM for each platform is not required we are concerned, there is an official team treatment), the project that is It can run on the platform, which is written in Java once declared, run anywhere. Premise running everywhere, and everywhere the need for implementation of the JVM.

JVM where it acts as an intermediate layer, the isolation of the development environment and operating system.

Isolation of the benefits is the elimination of mutual influence and not suited to direct contact between the two sides brought these are JVM this layer of the invisible.

Project developers do not care what the underlying operating system, I just butt JVM. Any change in the operating system upgrade related to my business, this is a matter to be considered JVM.

To the operating system does not need to because you want to run your class and make any changes. This is also the JVM things to consider.

Those who do not know how can I spend in design mode

Proxy mode
regarded as simpler design mode is also a relatively easy to understand, a see FIG.

Proxy mode .png After the agent with the middle layer of the caller who does not know the real situation of the actual class, so that one can hide information about the actual class, on the other hand can control the caller and the actual class in the proxy layer, you can do some restrictions on operations, or add some other processing logic, such as the common output before and after the call log. And this process of invocation and practical classes is no perception.


Aspect Mode
Also look at a map
image.png
the middle of the intermediate layer after the appearance of this role, for the caller, it becomes a lot easier, hum hum rip rip the original tune 3, now simply a monotone.
Others include a lot of space limitations, not listed.

Messaging middleware

Here the main scene, said messaging middleware used under decoupling, elimination of dependence between the two services, with the messaging middleware can be realized, messaging middleware can not achieve it, can he achieve a middle exchange system is not a big , but need to invest time and energy, so we have a ready-made.

Under this scenario exclusively dependent decoupling between the two services is actually nothing to show off its real power lies in the addition of many-to-call structure between the intermediate layer after conversion to many-to-multi-service structure.

As shown below

Unnamed .png file Right than on the left is clearly not a little, map can see, there is a clearly written code that implements the premise.


Gateway

Or look at a map

Gateway .png

After adding the intermediate layer gateway, one can hide the real address access services, on the other hand for the caller to call for a unified entrance, and can add a global processing logic for all back-end services in a unified layer gateways, such as Kam right, limiting logging and so on.

As another project in the last scene

A scene before the project encountered was the need through a very complex statistical SQL final output of a customer wants, when a large amount of data query very slow, in real-time data do not ask, do not want to introduce unnecessary technical components under the circumstances, how to deal with this problem?

The solution is to add an intermediate result tables, regular SQL execution statistics will result to the results table, query functions directly query the results table, it is easy to solve. FIG processed as follows

Results Table (1) .png

These are just a partial list of the contents, it can only be left to the reader did not mention found myself comprehend their own.

to sum up

Examples of binding above dismantling, under summarize, the middle layer designs can probably address the following scene.

Here special emphasis is to add a layer under a design, not only can solve the technical problems, work can also be used in everyday life, so the key is the key to the need to absorb this design.

 

For the technical back to the scene handled different scenarios will be different, not necessarily have to be introduced into such a technology component, such as under certain scenarios, add fields, add a class can be achieved. Be sure to learn and use.

Decoupling

The purpose of decoupling is to follow scalable, maintenance, upgrade software can be modified, to ensure their independent evolution.

polymerization

In order to simplify and facilitate access to the upper layer calls a result, adding a polymeric intermediate layer, there is little band decoupling and hide the details of the action, although not the focus of the polymerization, but it does have this effect.

Unified treatment

Typical application scenarios and scenarios as mentioned above, a gateway, such as an authentication center, logging can all be done at the gateway uniform.

Hide details

There is no system some of their own little secret do not want to let the public know that there how to do? Plus an external call level, hide the real service address, change the method name, change all the parameters you want to do can be done.

Differences shield

Corresponding scenario mentioned above did not, in fact, take a design mode for the appropriate adapter, a typical scenario how the plug in a two interpolated to a three socket. Middle of a transducing head can be done. Adapter indirectly by the difference between the interface shield.

Corresponds to the system, too, is an interface output xml, and the other is JSON recipient needs, can not be changed in both of the case, how to do that is to add a layer of intermediate conversion. Shielded difference data packets.

At last

In fact, good design can avoid some technical problems to a certain extent, simplify the problem scenario, which we need to continue to explore, keep trying, keep learning, constantly sum up.

Feel okay, leave fingertips praise.

These are today's content, see our next issue.

Guess you like

Origin www.cnblogs.com/yuboon/p/12117938.html