Layer mode-schema-Oriented Architecture learning notes

Source: Internet
Author: User
Tags define abstract

This is a new field for me, so it seems a little hard at the beginning. We hope that we can enter the status slowly. You may need to take notes for help. In my studies, learning notes play a very important role. He does not only record, but more importantly, he helps me think more deeply. I will feel that I have not learned anything without taking notes.

1.1.1. Layer

The system can be divided into subtask groups, each of which is at a specific abstract level.

1.Example

Iso7 layer model.

2.Context

A large system to be decomposed

3.Problem

Suppose there is a system that obviously blends underlying and high-level issues.

Mandatory conditions:

1) changes in one place are restricted to a component or layer and will not spread to the entire system.

2) the interface should be stable and can even be limited by standard parts.

3) each part of the system can be replaced. components can be replaced by other implementation methods without affecting other parts of the system. It may be based on excellent interface definitions.

4) it may be necessary to establish other systems in the future. These systems have the same underlying problems as the currently designed systems.

5) similar responsibilities should be grouped to improve comprehensibility and maintainability. Each component should be cohesive (how to improve the cohesion of the component? Let it do its own thing, and do not overstep the Authority .)

6) is there no standard component granularity? Why?

7) complex components need to be further decomposed. Yes, it can be broken down into child components within the component. If it is still too complex, you can consider dividing it into several layers.

8) Cross-component boundary may affect performance.

9) when the interface is clearly defined, the system canProgramTo create a group.

4.Problem

Divide the system into N layers, starting from the lowest abstraction level, increasing up until the N layer.

5.Problem

The main structural feature of the layer mode is that the services in the J layer are only used by the J + 1 layer-there is no further dependency between layers. Each Independent layer should prevent high-level direct access.

6.Dynamic Features

The following are scenarios:

1) A client sends a request to layer N, but layer n cannot complete the service, it needs to call the service at the N-1 layer to complete the service. And so on, N-1 calls N-2, N-2 calls N-3 ...... Until the bottom layer of the call completes the service, and then the service call result is fed back to the top. The top-down communication in this description. One such request may correspond to multiple underlying service calls.

2) Describe bottom-up communication-generally receives an underlying signal. For example, the driver checks that one receives a message and transmits it layer by layer. The first is generally called a request, which can be a notification. Similarly, several notifications may be combined into a more advanced notification.

3) requests or notifications only need to pass through a subset of the entire system. For example, layer n-1 can provide services. Alternatively, the underlying notification layer 2nd can be processed.

4) includes two protocol stacks for mutual communication.

7.Implementation

1) define abstract principles for grouping tasks. The abstraction criterion determines the number of abstraction layers.

User-visible elements

Specific Application Module

Public service layer

Operating System Interface Layer

Operating System

Hardware

2) define the number of abstraction layers based on the abstraction criterion. Each abstraction layer corresponds to a layer in the pattern. If the abstraction layer is too complex, further decomposition may be required. Control of the number of layers: a few layers are too complex, which may lead to unnecessary expenses.

3) name each layer and define their tasks. Ask him for a good, short name. If your name is very long or difficult to start, it may indicate that you are not thinking about this layer, and you need to further break down or adjust this layer. Improve the cohesion of the layer. If the top-down mode is used, the top layer is the function of the entire system, while the other layer is his assistant.

4) Specify the service. The most important principle is that the layers must be strictly separated from each other. No component spans more than one layer. The words in the brackets are not fully understood (It is better to put more service layers at the higher level than the lower layer. This is because developers do not have to learn the many nuances of their friends. They can even learn more during parallel development. The extended top layer is suitable for wider application areas, while the base layer remains slim. This phenomenon is also called the "reverse reuse pyramid").

5) Refined hierarchy. Repeat steps 1 ~ 4. In this way, a better hierarchy can be obtained.

6) specify an interface for each layer. Try to use the black box method-that is, the J-1 layer to layer J is black box, it only provides external interface, and outside does not know its internal structure and implementation (In fact, it is interface-oriented rather than implementation-oriented programming.). Design a flat interface to provide all layer J services, and may encapsulate these interfaces in a facade object .? (What is a flat interface? Whether the interface has no hierarchical relationship?)

7) build an independent layer. Not only must we design a reasonable interlayer structure, but also the internal structure of the layer be reasonable. If the layer is too responsible, you can consider splitting the layer into multiple components. If it is too complex, you need to consider generating a new layer. The component design can be optimized in other modes.

(8) Specify the communication between adjacent layers. This includes push mode, pull mode, and callback.

9) Separate the adjacent layer. This is not fully understood. The bottom layer is usually adjacent to the top layer, and the bottom layer does not care about the user's identity. This means that only one connection is allowed: the interface and semantics of the Service changed by modifying layer J remain stable. Changes in layer J can ignore the existence and identifier of layer J + 1 (I think there are some translation problems here. The general idea here is that if the persistence layerJ(Service Interface and semantics). At this time, layer JCan ignore layer J. This should be the separation.).

For bottom-up communication, you can use the callback function and keep the top-down single-channel coupling. The high-level register the Event Callback Function to the underlying layer (I have used this function ). In this case, we can consider using the reactor mode and command mode .??? I don't know if it is the original translation,ArticleThe description is rather obscure. What is clearly defined is usually quite complicated.

10) design an error handling policy. For a layered architecture, error processing costs a lot in terms of processing time and programming. One principle of error handling: Try to handle the problem at the underlying level. Even if it is to be processed by a higher level, it should be converted into a type of error that the higher level can understand. In addition, reduce the error types and merge them as much as possible.

8.Example

TCP/IP.

9.Variant

1) loose layered system. There is no strict constraint between layers. This solution loses maintainability and achieves flexibility and performance. This should be used with caution. It is usually seen in the infrastructure.

2) hierarchy by inheritance. The underlying layer is implemented as the base class, and the high-level layer is a subclass of the underlying layer. Therefore, it can request services from the base class. The advantage is that the high-level can modify the underlying service as needed. The disadvantage is that the integration relationship closely binds the high-level layer with the underlying layer. The coupling between layers increases.

10.Known applications

1) virtual machines add an indirect layer on the operating system and hardware.

2) API,

3) information system,

11.Effect

Advantages:

1) layer reuse. If an independent layer represents a well-defined abstraction with well-defined and documented interfaces, this layer can be reused in multiple contexts.

2) support for standardization.

3) Local dependence. The impact of changes to the lower layer on other layers.

4) it can be used for replacement.

Disadvantages:

1) Overlapping changes. A change may run through the entire hierarchy.

2) reduce efficiency.

3) unnecessary work.

4) It is difficult to recognize the correct granularity of the layer. Too few layers are insufficient to make full use of the reusability of this model, which can be modified and has the potential for portability. Excessive, it will introduce unnecessary complexity and the redundancy of Inter-layer separation.

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.