[Add to favorites] Introduction to the classic architecture model of the software architecture and Model

Source: Internet
Author: User
According to Linda Rising's book pattern almanac, there are more than 70 known architecture models. This is only a lot of statistics, including a lot of patterns that are generally considered to be design patterns, such as bridge, facade, interpreter, mediator and other models are generally considered as design patterns, however, in many cases, it can also be used as an architecture model, so it is often used as an architecture model.

  Layers architecture Mode

After collecting users' requirements for the software, the architecture design begins. The main purpose of architecture design is to divide the system into many "sections ". There are usually two ways to divide, one is horizontal division and the other is vertical division.

Horizontal division divides the system according to business purposes. For example, a bookstore management system can be divided into purchase, sales, inventory management, and employee management.

Vertical division is different. It divides the system into layers or layers based on the level of abstraction. For example, a company's Intranet management system can be divided into the following layers:

1. webpage, that is, the user interface, is responsible for displaying data and accepting user input;

2. The domain layer, including JavaBean or COM objects and B2B services, encapsulates necessary business logic, determines what data to display and how to calculate based on user input data based on business logic;

3. databases are responsible for storing data and providing the stored data according to query requirements.

4. operating system layer, such as Windows NT or Solaris

5. hardware layer, such as Sun e450 Server

Some people call this layer a tier, but tier has many physical meanings. different tiers are usually located on different computers and connected by networks, while layer is a concept of pure logic, it has nothing to do with physical division.

The advantages of the layers architecture model are:

1. Changes at any layer can be well confined to this layer without affecting other layers.

Second, it is easier to accommodate new technologies and changes. The layers architecture model allows the technology used by any layer of change

  Fa? Ade Architecture Model

External communication with a sub-system must be performed through a unified facade object, which is the facade mode.

Modern software systems are complex. The task of designing a model is to help designers deal with the design of complex systems.

A common way for a designer to process a complex system is to divide it into several smaller subsystems. However, after doing so, designers often find that there are still too many types to process in a sub-system. However, when using a sub-system, the user usually only pays attention to some specific functions, but must deal with many objects in the sub-system at the same time to achieve the goal. For more information, see the following object diagram.


Figure 4. Structure of the facade architecture mode.

This is an inconvenience. It makes the system logic unnecessary, increases maintenance costs, and reduces the reuse rate.

An example shows that a hospital in mainland China is a sub-system. According to the Department's functions, this system can be divided into registration, outpatient service, price assignment, testing, cash register, and drug withdrawal. It is not easy for a patient to deal with these departments, just as the user end of a sub-system deals with various types of a sub-system.

First, the patient must register first and then go to the clinic. If the doctor asks for a test, the patient must first make a price and then make a payment to go to the test department for the test. After the test, return to the clinic. See the object diagram below.


Figure 5 describes the patient experience in the hospital. The box in the figure represents the hospital.

The facade mode is introduced to solve this inconvenience. The hospital example shows that you can set up a receptionist's location. The receptionist is responsible for registration, price assignment, payment, and drug withdrawal. The receptionist is the embodiment of the facade model. The receptionist is only in contact with the receptionist, who is responsible for dealing with various departments of the hospital. See the object diagram below.


Figure 6. Describe the patient experience in the hospital after being modified in the facade mode. The box in the figure represents the hospital.

The facade mode requires that the external communication of a sub-system and its internal communication must be performed through a unified facade object. The facade mode provides a high-level interface to make subsystems easier to use.

After the facade mode is used, the complex relationships faced by the user-side objects of a sub-system described in the first graph in this chapter can be simplified as follows.


Figure 7 structure of the facade Architecture

Describes the relationship between the user end and the subsystem of a sub-system after being modified in the facade mode. The generous box in the figure represents a sub-system.

Just like the Hospital Receptionist, the facade mode facade type separates the internal complexity of the user end from the subsystem, so that the user end only needs to deal with the facade object, instead of dealing with many objects in the subsystem.

  Mediator architecture Mode

The mediator mode encapsulates a series of ways for objects to interact with each other, so that these objects do not have to be explicitly referenced; thus, they can be loosely coupled. When the interaction between some objects in these objects changes, it does not immediately affect the interaction between other objects; thus, these interactions can be changed independently.

There are a large number of objects in the following. These objects affect other objects and are affected by other objects. Therefore, they are often called colleague objects. These colleagues interact with each other to form systematic behavior. It can be seen that almost every object needs to interact with other objects, and this interaction represents a direct coupling between an object and another object.


Figure 8. This is an over-Coupled System

By introducing a mediator object, you can change the system's mesh structure to a star structure centered on the intermediary, as shown in. In this star structure, the colleague object no longer interacts with another object through direct connections; on the contrary, it interacts with another object through the mediator object. The existence of the Mediator object ensures the stability of the object structure. That is to say, the structure of the system will not be greatly modified because of the introduction of new objects.


Figure 9. structure diagram after using the mediator Architecture

Compared with traditional design methods, object-oriented technology can help designers better manage more complex systems. A good object-oriented design can increase collaboration between objects and reduce coupling ). A well-thought-out design Splits a system into a group of cooperative colleagues, and then gives each colleague an unique responsibility to properly configure the collaboration relationship between them, so that they can work together.

In mediator mode, all member objects can be coordinated, but cannot be managed directly. These objects are closely related to a central mediator object, which coordinates the work. This coordinator is called a mediator, and the member object coordinated by the Coordinator is called a colleague object.

Events occurring within the colleague object will affect all colleagues, but this impact is not directly transmitted to other objects through direct management. Remember that when group members increase, such interactions increase faster than the index. On the contrary, this effect only directly affects the object of the Mediator, and the object of the mediator, in turn, coordinates other colleagues to form the behavior of the entire system.

If the number of members in the group increases, the contact person may face changes, while other colleagues may pretend that they do not know the new member and do not need to modify it. In turn, if one of the members of the group is deleted from the system, the mediator object needs to make changes to the change, and other colleagues in the group do not have to make any changes.

  Interpreter Architecture

Given a language, the interpreter mode can define a representation of its syntax and provide a literal interpreter. The user can use this interpreter to explain sentences in this language.

If a type of problem occurs repeatedly, it makes sense to express each instance of the problem as a statement in a simple language. In this way, you can build a literal interpreter to solve the problem by interpreting these statements.

For example, searching for strings in a matching mode is a common problem. Instead of building a specific algorithm for each matching pattern, it is better to build a general algorithm to process various regular expressions. When receiving a specified regular expression, the system uses a literal translator to interpret the Regular Expression and match the string.

For another example, VBA (Visual Basic for Applications) is not only used in Microsoft's office software series, but also can be embedded and used by third manufacturers; the Crystal Reports report generation software also includes an easy-to-use macro language, allowing you to execute more complex command operations. Generally, embedding VBA or other language software into your own software products can greatly enhance the customization capability of products, but these macro language engines are often very expensive.

The interpreter mode to be introduced now describes how to explain these statements using schema design after a simple syntax is available. After being familiar with this mode, a designer who has not received formal training in formal languages and compilers can also design a simple literal interpreter to provide a simple language for the user end, or use a simple language inside the system to describe an appropriate problem.

  Language, interpreter, and parser

The interpreter mode only describes how the literal interpreter works and does not specify how to create a new literal interpreter during execution. In a broad sense, though the interpreter does not have to have a parser, it is still the most common method to create a interpreter. A parser can read text commands from a file or command line and create a literal interpreter.
The parser is an object that can recognize text and break down the text according to certain rules for further processing. The strings recognized by the parser are called languages. Generally, a small computer language is a language unrelated to the environment, that is, a text model that follows a certain grammar. The so-called grammar is a set of rules that determine how to combine language elements. The parser splits strings according to the combination rules.

In abstraction, the language is not necessarily expressed in the form of strings. The language mentioned in interpreter mode refers to any combination that any literal translation object can interpret. In interpreter mode, you need to define a hierarchical structure that represents the syntax command type, that is, a series of combination rules. Each command object has an interpretation method, which represents the interpretation of the command object.

Any arrangement and combination of objects in the hierarchical structure of command objects is a language, and the profiling tool translates a text language into an equivalent literal translation language. Therefore, the interpreter is often needed.

  Do you know Jack??

Parser Generator is often called the compiler ). Sun Microsystem provides a powerful parser generator designed for Java Programmers. It was originally called Jack and later renamed javacc.

To use javacc, you must use the script language provided by it to write a script, and then execute javacc to generate the Java source code. The generated source code is the necessary parser. Sun is no longer responsible for javacc R & D. Readers interested in javacc can get free javaccesand related data from http://www.experimentalstuff.com/policies/javacc.

Javacc was first named Jack to enable homophonic sound with a long-used Parser Generator YACC. If you are familiar with YACC, you can use YACC for the same purpose. In contrast, javacc is easier to get the favor of Java programmers.

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.