Root According to Linda Rising's pattern Almanac has over 70 known architecture models. This is only a lot of statistics, including many models that are generally considered as design patterns, such Bridge, facade, interpreter, mediator, and other models are usually considered as design patterns, but in many cases, they can also be used as architecture patterns. 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 Facade architecture Mode 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 a sub-system still has Too many types need to be processed. 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. The image of this topic is as follows: 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. The image of this topic is as follows: 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. The image of this topic is as follows: 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. The image of this topic is 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 Interact with each other to form system 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. The image of this topic is as follows: 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, colleagues' objects are no longer directly connected. The system interacts with another object. On the contrary, it interacts with another object through the mediation object. The existence of the Mediator object ensures the stability of the object structure, that is, the structure of the system will not The introduction of new objects causes a lot of modification work. The image of this topic is as follows: 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 enhance collaboration between objects (Collaboration) to reduce coupling ). A well-thought-out design will break down a system into a group of cooperative colleagues and then give them to each colleague. With unique responsibilities, you can properly configure the relationships 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. Objects for coordination. 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 this when the group members increase The Interaction Relationship increases 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 example, VBA (Visual Basic Applications) not only appear in Microsoft's office software series, but also can be embedded and used by third manufacturers; Crystal The reports report generation software also provides an easy-to-use macro language that allows you to execute complex command operations. Generally, you can embed VBA or other language software into your own software production. Product Customization capabilities can be greatly enhanced, 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 language that has not received any formal language or code Designers of the interpreter's regular training can also design a simple literal translator to provide a simple language for the user side, or describe an appropriate problem within the system using a simple language. 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 irrelevant to the environment. A language is a set of rules that determine how to combine the elements of a language. 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 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 that represents Description. 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 Complier ). 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. Now sun has No longer responsible for the development of javacc, javacc interested readers can http://www.experimentalstuff.com /Technologies/javacc get free javacc and related data. 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. |