"Design Mode Analysis" Chapter 5 Design Mode Introduction

xiaoxiao2021-03-06  47

Chapter 5

Design mode introduction

Overview

This chapter introduces the concept of design pattern.

In this chapter,

l I discuss the origin of design patterns in architecture and how they are applied to software design.

l I discuss the motivation of learning design patterns.

The design pattern is the forefront part of object-oriented technology. Object-oriented analytical tools, books, and seminars include design patterns. Learning groups about design patterns are all. Usually there is such a suggestion that people only go to study design mode after mastering basic objective skills. I found that it is true: learning design mode in the early stage of object-oriented skills, which is beneficial to improve the analysis of surface-to-face object analysis and design.

The entire remainder of this book, I will not only discuss design patterns, but also discuss how they are showing and consolidating the object-oriented principles. I hope to improve your understanding of these principles and clarify why the design patterns discussed here represent a good design.

Some of this chapter look like abstract or philosophy. But please give it a chance! It makes you understand the cornerstone for you to understand the design pattern. The understanding of it will enhance your ability to understand the new mode and the ability to get along with them.

Many of my thoughts come from the "Eternal Road of Architecture" [1] for the Christopher Alexander [1]. I will discuss these ideas in all books.

The design model originated from architecture and anthropology

A year ago, an architect named Christopher Alexander asked himself, "Is the quality objective?" Beauty, is it true in the eyes of the viewer? Alternatively, people agree that certain things are beautiful and certain things are not beautiful? Now, Alexander is interested in this special form of beauty has become a kind of building quality: What makes us know when a architectural design is good? For example, if a person is designing an entrance for a house, how do he know this design is good? Can we distinguish it? There is an objective basis for judging, a basis for describing our consensus?

Alexander assumes that there is such an objective basis in the building system. Judging the beauty of the building is not a simple style problem. We can describe beauty through a measurable objective basis.

The discovery of cultural anthropology discovered the same thing. Its work main body proposes, what is considered a good design, what is the problem of beauty, the individual in the same culture will agree with the public opinion. Culturally makes a judgment of personal beliefs. I believe that there is a transcendence pattern, which is used as an objective basis for evaluation design. A main branch of cultural anthropology is looking for models to describe cultural behavior and value. [2]

The protocol behind the design model is that the quality of the software system can also be objective.

If you agree with and describe a high quality design, how do you create such a design? I seem to see Alexander asking himself,

What is existing in high quality design, but does not exist in low quality design?

as well as

What is existing in low quality design, but does not exist in high quality design?

These issues originate from Alexander's belief: if the quality in the design is objective, then we should have the ability to identify what makes the design become a good design, what makes it makes design become bad design.

Alexander studies this problem by conducting a lot of observations for each other living space built for buildings, towns, streets, and in fact. He found that there is a common thing to create a particular building.

Even with the same type of building structure, they are different from each other. Despite this, they may still be high quality.

For example, two seemingly structurally different corridors, they may be considered high quality. They may solve different problems for different homes. A corridor may be a transition from the walkway to the front door, and the other entry can be a cold in hot days; or two corridors may solve a common problem in different ways (transition). Alexander understands this. He knows that the structure cannot be separated from them to solve. Therefore, in his exploration of the design quality consistency, he recognizes that he must view different structures designed to solve the same problem. For example, Figure 5-1 shows two options that distinguish an inlet channel issue.

Figure 5-1 The structure may differ, but still solve a common problem.

Alexander finds that by narrowing his focus in this way - through the structure of the similar problem - he can identify the similarities between high quality design. He said that these similarities are mode.

He defines a solution to a solution in a background. "

Each mode describes a question that appears repeated in our environment, then describes the core of its solution so you can use this program to do twice without need to do it in the same way. [3]

Let's review some of the results of Alexander to illustrate this. In Table 5-1, I will show an excerpt from the "Eternal Road" [4] of the "Architecture." This excellent written a concise introduction to the philosophy of the model.

Table 5-1 is taken from "The Eternal Road of Architecture"

Alexander said ... My comments ... A proper garden, help people live in the same way. A model always has a name, a goal. Here, the name of the pattern is the courtyard, and its purpose is to help people live in it. Consider the forces at work in a courseord. The most important thing is that people seek some private outdoor space, where they can sit down the sky and see the stars, sunburn the sun, or flowers. This is very obvious. Although this seems to be obvious, it is still very important to clearly state the problem solved. This is the primary reason for the mode of use. This is what Alexander is a courtyard. But there is still a more subtle forces. For example, when a yard is surrounded by a wall, there is no outward perspective, people will feel uncomfortable and want to leave ... they need to see some more and more distant space. He pointed out the difficulties of using a simplified program, then, he gave us a solution to us. Or again, people are the product of the habit. If they go into this yard every day, it will become more familiar and become a natural place ... This is used. Sometimes familiar will block us from seeing those things that are obvious. The value of the pattern is that those who lack experience can take advantage of others before them: those must be included in a good design and avoiding embarrassing design. But there is only one courtyard in an internal, one is only when you "think" you will go, is a place where you are unfamiliar, often abandoning ... People are more familiar place. Is there a transition space - a corridor or veranda, under the top cover, but open in the air - in psychology, this is a fold between indoors and outdoor, making you bring you to the courtyard It is easy to easily simply simply, and he suggests a solution to the challenge to build a big garden. When a garden has a perspective, you can see a larger space, there is a crossover from different rooms, and have a veranda or corridor, these forces can solve themselves. The outward perspective is comfortable and intersecting to generate habitual feelings, the corridor makes frequently become easy ... and this courtyard gradually became a conventionally comfortable place. ... and will tell us why it is powerful.

Let's do a review. Alexander said the model's description contains four terms:

l pattern name

l Mode purpose, it solves the problem

l How do we achieve your go?

l In order to achieve the purpose, we must consider limitations and forces.

Alexander assumes that the mode can solve every construction problem that people will encounter. He further assumes that models can be used to use to solve complex construction problems.

How to work with how to work will be discussed later in this book. Now I am focused on the model that helps to solve a particular problem.

From architecture mode to software design mode

What is the fact that all this group of people in architecture is related to our software developers?

This is the case, some smart developers have discovered the Alexander's mode works in the early 1990s. They want to know if there is a true thing in the architectural mode. [5]

l Whether the problem in the software repeatedly appears can also be solved in a certain way?

l Whether after the mode is identified, it is possible to design the software through the mode, based on their specific solution?

These people think that the answer to these two questions is "unfunusal correct." Next, it is to identify several modes and develop a standard for new models.

Although many people have an impact on design patterns early in the early 1990s, the biggest book for this lack of experience is Gamma, Helm, Johnson and Vlissides "Design mode: can be used object-oriented software Basic "[6]. In order to commend the important work of these four authors, they were wide and intimately crowning.

This book has several functions:

l It uses the idea of ​​design patterns to software design.

l It describes a structure and classifies and describes design patterns within this structure.

l It is classified 23 such modes.

l Based on these design patterns, it assumes object-oriented strategies and ways.

One is very important. These four authors did not create the patterns described in the book, but identified these modes. Because patterns have existed among the software community, they reflect people's understanding of high quality design for specific issues (note and similar Alexander's work).

Today, there are several different forms describing design patterns. Since this is not a book written design pattern, I will not give the best structure about describing the design model. However, the clauses listed in Table 5-2 need to be included in any description.

I will summarize the key features describing this mode in every pattern introduced in this book.

Table 5-2 Key features of mode

Clause Description Name All modes have a unique name that indicates their name. The purpose of intent mode. Problem mode The problem scheme is how to provide solutions for issues in the background of the background. Entities involved in participants and collaborators models. Results The results of the mode. Research uses this pattern for Forces. How to implement the model can be implemented. Note: Implementing only the specific performance of the pattern, should not be interpreted as the pattern itself. GOF reference needs to access more information in the four-person text.

Results / forces The results were used in design modes and often misunderstood. In daily use, the word is usually derogatory. (You will never hear someone say, "I have a six-color lottery! That is, if you implement this mode with a certain method, this is how it will affect and be affected by the forces present.

Why study design patterns

Now, you have a little idea for the design mode, you may want to ask, "Why study them?" There are several reasons herein, and there are several reasons are not so obvious. The most common reason for learning mode is because models allow us:

l Reuse Solutions - I have gained ahead of my question by reusing the established design. I have to learn the benefits of others' experience. I don't have to re-invent solutions for issues that always repeat them.

l Establish a common gloss - Communication and team collaboration require a common vocabulary basis and a common point of view of issues. In the analysis and design phase of the project, the design mode provides a common reference point.

However, there is a third reason for learning design patterns:

During the design and object-oriented process, the mode gives you a high-level perspective of the problem. This is freed from the tyranny of premature treatment details.

At the end of this book, I hope that you will agree that this is a biggest reason to learn design mode. It will convert your thinking habits and turn you into a more powerful analyst.

To illustrate this good, here I want to quote a two carpenter's conversation on how to make drawers for some cabinets. [7]

Imagine two carpenters are discussing how to make drawers for some cabinets.

Carpenter 1: How do you think we should make these drawers?

Carpenter 2: Well, doing such a connector, I think we should cut down to the wood, then turn back to cut in the 45-degree corner direction, then turn back straight down, then turn back to cut up in another 45 degree angle, then turn back straight Divide, then ...

Now, please tell me what they are talking about!

Isn't it a puzzling description? What is the carpenter 2? There is no doubt that the details hinder us! Let us care about his description.

Carpenter 2 said ... It seems like ... "Well, doing such a joint, I think we should go straight into the wood, then turn back to cut up in the 45-degree angle direction ..." "" Take back straight down, then look back The other 45 degree angle is cut up, and then the pen is cut down, then ... "" "... until you complete a dovetail connector. That is what I just described!"

This sounds like a code review like you have heard? There is a programmer to describe the evaluated code:

Then, I use a While loop to do ... followed by a series of IF declarations ... I will use a switch to deal with it here ...

You get a description of a code detail, but you don't know what this program is doing and why do you do it!

Of course, a carpenter with self-esteem is not talking like this. What truly will happen:

Carpenter 1: Are we using a dovetail joint or a slope joint?

We have seen a different nature. The carpensels discussed the difference between problem solutions; their discussion is at a higher, abstract level. They avoid caught in a mud in a special solution detail.

When the carpenter talked about a bevel joint, his or her mind had the following characteristics:

l This is a simple solution - the bevel joint is very simple. You cut the edge of the connection block with a 45-degree angle, adjacent them, and then nail it together with a nail or bonded with glue. (Figure 5-2)

l It is a lightweight-beveled joint is not as strong as the dovetail joint. It cannot withstand huge pressure.

l It is unhappy - compared to the plurality of cuttings of the dovetail joint, the single cutting of the bevel joint is not attractive.

Figure 5-2 A slope joint

When the carpenter talks to the dovetail joint (we described how to make it on page 81), the programs in her brain have another characteristic. Perhaps these characteristics are not obvious, but they are clearly understood by any carpenter. l It is a more complex solution - making a dovetail joint more tricky, so it is more expensive.

l It is not affected by temperature and humidity - when these conditions change, the wood will be stretched accordingly. However, the dovetail joint will remain firm.

l It does not rely on the fastening system - in fact, the dovetail connector can work without relying on glue.

l It is a more beautiful connection - how to do it, it looks very beautiful.

In other words, the dovetail connector is a firm, independent, beautiful connection, which is complex (therefore also expensive).

Therefore, when the carpenter is asked,

Are we using a dovetail joint or use a bevel joint?

What is the truly proposed question is,

We use a joint to manufacture expensive but beautiful and durable, or just make a quick and simple, just insist on the end of the inspection?

We can say that the discussion of the carpenter is in fact, in two levels: the surface layer of the speech, as well as the true conversation, the latter happens in a higher level (a meta-level), it isolates the outer line and contains rich Most. This higher level is the "carpenter mode" level, which reflects the real design problem of carpenters.

In the first case, carpenter 2 makes it unknown because of discussing the details of the joint. In the second case, the carpenter 1 wants to decide which connector to use based on cost and quality.

Who is more efficient? Who are you more willing to work?

This is one of the meaning when I say mode can help improve your ideological level. Behind this book you will see that when you improve your ideas like this, new design methods will become tentacles. This is the true power of the model.

Learn other benefits

With the use of the development group, my experience is that design patterns help personal learning and team development. This is because the newcomers in the team see those senior developers who are familiar with design patterns have some valuable things, they also want to get it. This provides them with power to learn some powerful ideas.

Most design patterns simultaneously make software easier to modify. This is because they are the solution to the time inspection. Therefore, it has been developed into a structure that can be more easily handled more easily.

If it is taught, the design model can be used to greatly improve the understanding of the basic principles of the face-to-face object design. I have seen countless times in an object-oriented course in the introduction of our professors. In these classrooms, I started with a short-oriented paradigm. Then I started to teach the design mode, use them to explain the basic object-oriented concept (package, inheritance, and polymorphism). Although we have been talking about models most of our time, these ideas have been introduced to many participants before the end of the three-day course, which makes people feel like old friends.

For the creation of a good object-oriented design, the four groups suggested several strategies. The following is that they are specially suggested:

l - based interface design.

l Prior to use combination, not inheritance.

l Look for changes and package it.

These strategies are used in most design patterns discussed in this book. Even if you don't know a lot of design patterns, learn some will make you know why these strategies are useful. With that understanding, even if you don't directly use the design pattern, you also have the ability to apply them in your own design problem.

Another benefit is that the design pattern allows you or your team to create a design for complex issues without having a large inheritance level. Similarly, even if the design pattern is not directly used, avoiding a large inheritance level will also result in improved design. to sum up

In this chapter, I described what is design mode. Christopher Alexander says "Mode is a solution for a background." They are more than just a template for personal problems. ............. ...

I also view the reasons for learning design patterns. Such learning helps

l Rears existing, high quality solutions that usually have repeatedly occurred.

l Establish a public glossary to improve the communication within the team.

l Convert the ideological level to a higher perspective.

l Determine if I have a correct design, not just a designed design.

l Improve personal learning and team learning.

l Improve the modality of code.

l Help adopt improved design choices, even when the pattern is not explicitly used.

l Discovering a substitute for a large inheritance level.

[1] Alexander, C., Ishikawa, S., Silverstein, M., Architectural Eternal Road, New York: Oxford University Press, 1979.

[2] Human scholars Ruth Benedict is a pioneer in terms of mode-based analysis of culture. See Benedict, R., Chrysanthemum and Sword, Boston: Hordon Mius, 1946.

[3] Alexander, C., Ishikawa, S., Silverstein, M., Mode Language, New York: Oxford University Press, 1977, P. X.

[4] Alexander, C., Ishikawa, S., Silverstein, M., Eternal Road, New York: Oxford University Press, 1977.

[5] Europe's ESPRIT community is working similar effort in the 1980s. ESPRIT 1098 and project 5248 have developed a mode-based design method, which is called knowledge analysis and design support (KADS), which focuses focus on the mode used to create an expert system. Karen Gardner extends the KADS analysis mode to an object-oriented. See Gardner, K., Cognitive Mode: Object Technology Problem Solution Framework, New York: Cambridge University Press, 1998.

[6] Gamma, E., Helm, R., Johnson, R., Vlissiders, J., Design mode: The foundation for object-oriented software, Reading, Mass: AddIn-Wesley, 1995.

[7] The inspiration of the conversation comes from a period of Ralph Johnson, and passes the author's adaptation.

转载请注明原文地址:https://www.9cbs.com/read-71744.html

New Post(0)