Sunday, February 27, 2011

Design Patterns and XP

 Transfer from CSDN
Design Patterns and XP
Joshua Kerievsky with, Gigix translated

patterns and Extreme Programming overview (XP) are for software design, development can not provide a monetary measure of help. But So far a lot of attention in the reconstruction of XP (refactoring), but made no mention of the model. In this article, I asked XP contains a model for how to use the better.
thank
thank Kent Beck, Martin Fowler and Ward Cunningham, who made a friendly for this article's comments.
still know much of the time we started his career in program design and produce software that also reflects our lack of experience:
we created the code bloated, buggy, fragile, difficult to maintain, difficult to expand. As time the passage of time, we became a better software designer: We from the technical writers, experts in learning, we learn from their mistakes. Now we have a high degree of flexibility in writing software that meet the broad and strong. When writing a request a new system, we know to identify current and future needs, so that we can design the software to handle current and future needs.
career in software development at this stage, extreme programming tells us that we too often software design (over-engineer) the. We learned from their mistakes too many, we do not want to repeat these mistakes in the system life cycle, so we did a lot of early efforts to create a flexible and robust design. Unfortunately, We did not realize that: If the system never need this degree of flexibility and robustness, we all to no meaningful work. We over-designed.
I have also over-designed. tell the truth, and sitting in a room other designers to consider how to design software to meet the many current and future needs, it is indeed a pleasure. we have all the things he learned mm the best experience, especially those used in the design of mm .
We often know the needs of the list will change, but the user or customer needs are always changing. However, we think we can be smart enough to design software, the software flexible enough to enable it to meet the changing needs of all.
A typical over-design.
today, extreme programming will tell you how stupid this is the practice. XP, we must design their own apparent, rather than to predict the design will look like. XP says, probably the most simple things work,
you need to emphasize communication in a simple, feedback and courage to choose the best value system in the methods of work, so you can communicate you need to emphasize in a simple, feedback and courage to choose the best value of the work system method, so you can communicate you need to emphasize in a simple, feedback and courage to choose the best value system in the methods of work, so you can communicate you need to emphasize in a simple, feedback and courage to choose the best value system methods of work, so you can brave from the over-design. brave from the over-design. brave from the over-design. brave from the over-design. Beck1 00?
agree. But now I must mention my friend Norm Kerth. Norm in the field of software development experience and knowledge. A year ago I asked him . My concern is: what is not everything in the. Kerth 99?
At the time, I think Norm is a conservative. But now I'm not sure the. XP is the obvious lack of experience in using the model. Although some of the founders of XP to help build a model community, but there is no clear indication which model how a firm to adapt to XP.
the beginning, this has not made me feel confused. But now, I really am confused.
I am confused, because I experience on XP and models so I believe: the scene in the XP model will work better; and when the XP package
including mode, XP will work better.
This requires some explanation. I will describe my own usage patterns and XP started some experience.
Since 1995, I began to immerse into the mode of being. I'm learning literature, hosted a weekly pattern study group, using the model design and development software, and UP (one on the International Conference on usage patterns) of the organization and functioning of work. that I was , as many people first learning, I have a little too eager to use them. This is not a good thing because it will make your design more complicated than they need. but I did not realize it until I started reconstruction study.
probably in 1996, my first exposure to the reconstruction. I began to observe positive remodeling it and soon left me with my study and learn in the mode of certain principles.
held example, that the landmark book mm programmed. GHJV1 95?
How do you get when the lack of software flexibility and modifiability. Almost every time the interface to come and help.
but if we do not need the flexibility and modifiability, the situation is? why we need to start designing Some may never anticipated and emerging needs? This is my first awareness. So then I recorded the following J AVA technique:
separation of classes and interfaces do not separate classes and interfaces that do not separate separation of classes and interfaces classes and interfaces
I have used the interface in my name followed by an name and interface name as designed. Here are the reasons: In the development process, you know that you can use an interface to allow certain things to be flexible (to diversify) but may be you do not need to diversify. So, put down the forecast too many , weeks, months, you clear the The statement remains unchanged. Kerievsky 96?
I continue to learn the curriculum is similar to reconstruction, gradually, I began to change in patterns of use. I no longer consider the use of models in advance.
Now, I am more sensible a: If a model can solve a design problem, if it offers a way to implement a demand, I will use it, but I can encode a model from the most simple implementation begins. Later, when I need to add or modify, I will make this implementation more flexible and stable.
this new method of using the model is a better way. It saves me time and make my design more simple.
As I continue to learn more knowledge about XP, I soon began to consider this fact: that clearly describes It seems all the focus has shifted from the development of reconstruction. tectonic point, test a little, little reconstruction, and then repeat.
then model how the?
I received the usual answer is: model to encourage over-design, and refactoring to keep things simple and lightweight.
Now, I like people like any other remodeling mm I reviewed the Martin Fowler's book on the subject of two manuscripts, and that reconstruction would be become a standard. but I still like the pattern, I found the model Pattern Repository wrote my anxiety. I asked: Is XP the perfect model should be completely unaware of patterns composed of programmers and guidance, whether they should rely solely on reconstruction to mode (in the general sense). he needed a beginner can not listen to the words of the code. He needs to learn the code quality of the model (in the general sense). he needed a beginner can not listen to the words of the code. He needs to learn the code quality mode (in the general sense). he needed a beginner can not listen to the words of the code. He needs to learn the quality of the model code (in the general sense).
optimistic about the code he needs (and, I guess, bad code), so that he can learn to write good code.
a problem, I mean is a possible question is, whether the model is used to help improve code quality. I think Beck's Smalltalk Best Practice Patterns will help, because those are very small models. I want to be helpful, because those are very small models. design patterns are more questionable, because the model and discuss the sometimes become quite large, and they may result seems a reasonable substantial design patterns are more questionable solution. Martin Fowler's excellent analysis of model also has the same danger: the choice of the exciting analytical model has the same risk: Before you can choose a small-scale solutions to the time Select a large-scale solutions. Jeffries 99?
a very interesting view on the model. Although I have seen the implementation model can be sensible, to use, but it looks recognize
Ron is dangerous for them because they I can not agree with this latter observation. Like anything new, or even XP mm mm, as one might use them too eager to make
. but the pattern is really to encourage use of small-scale solutions can be used to solve large-scale program do?
I think it depends on how you define, using the model. For example, I have observed many models of primary users, they think that a
a model and its structure (or class diagrams ) are identical. only when I pointed out to them the realization of a simple but also complex. The trick is: find patterns for the problem, the problem with your current problems are compared, then this model is the most simple implementation (solution) with your questions for comparison. When you In doing so, you will not be small-scale solutions can be used when using large-scale solutions. you get the best balance to solve the problem.
model when people did not receive good training, difficulties may arise . Ron mentioned that the way people use pattern is some time to understand the mode of solving the problem, so you can wise choice according to their specific needs model.
This choice is extremely important. If you choose the wrong mode, you may just put you over-design or design rub together. experienced model user can make mistakes, and often see such results. But there are other models such experts as the equipment, these models can help them face their own mistakes. so they often end the model you really need to replace the not so ideal model.
then you will experience how to become a model user? I find that unless people are engaged in a large number of modes of study, or they may into a misunderstanding of them, the excessive use of them and use them in danger of over-design.
mode but this is a reason to avoid using up?
I think not. I found the model in so many projects so useful , so that I can not imagine not using them for software design and development. I believe that a thorough study of the patterns is very worthwhile.
then, XP is on silent mode because they feel that the misuse of it?
If that is so, perhaps the problem has become: How do we use the model of wisdom, and to avoid the model how to use patterns in our intelligence, and how to avoid the model used in our model of wisdom, and to avoid mode How do we use the model of wisdom, and to avoid the XP development model in the development of the scene scene scene, the development of the development scene in the misuse of it? misuse it? misuse it? misuse it?
here I think I must return to the > We recorded a number of design patterns generated reconstruction of the design structure. early in the design mode to prevent the use of these design patterns we have recorded a lot of the design of the structure reconstruction. But even after completion of the system to know how to use these mode, they can still teach you how to modify your post-Reconstruction. But even after the completion of the system on how to use these patterns, they can still teach you how to modify your post-Reconstruction. design pattern for your re- provided the target structure. GHJV2 95?
This is what we need to view: Reconstruction of the goal. This is the bridge between the reconstruction and model. It perfectly describes how to use my own improvement models: from simple start, consider the model but will they remain in second place, small-scale reconstruction, only in real time mode only then need to transfer as a model reconstruction.
the need to carefully determine the process of training and will be a good fit XP contains best practice.
and this approach is obvious and danger is that: no goal, people may make the design a little progress, but their overall design will be the ultimate victims, because this lack of order, simplicity and effectiveness, and clever use of pattern allows developers to have these. < br> quote Kent Beck's own words: pattern formation pattern generation architecture architecture architecture patterns generated pattern generation architecture. Beck2 94?
but the pattern does not guarantee a disciplined use. If we are in the design too much, too soon use them, we went back over the design problem. Therefore, we must answer the question: quote:
early in the design mode to prevent future use of these reconstruction. early in the design mode to prevent future use of these reconstruction. early in the design mode to prevent future use of these reconstruction. use these patterns early in the design can prevent future reconstruction.
This is a clever idea. If we do not know br> Once again, the problem all together: how to project problems and an appropriate pattern to match.
here, I have to tell me to get different sectors of software development experience.
there is a customers asked me and my team with J AVA for their Web site construction software, which will be a cool interactive version. The customer does not have any J AVA programmer, but still require energy they need at any time, any place modify the behavior of the software without having to make program changes. how high the request!
needs to be done on some of their analysis, we found that in the Command design pattern will play a very important role. We will write command object, and object control software for these commands the entire act. Users will be able to parameterize these commands, sorts them, and choose the command to run the time and place.
This solution worked perfectly, Command mode is The key to success. So here, we will not wait until the reconstruction of the Command pattern when it is used. Instead, we advance to see the need to use it, and from the outset to design software with the Command pattern.
in another project, the system needs as a standalone application and WEB applications running. Builder mode in this system has played a huge role. Without it, I can not imagine how we will put together a bloated design. Builder is the role model solve the They look like the most primitive to achieve them. Only later, when the need for additional functionality, the mode of implementation can be replaced or upgraded.
an example will make you more aware of this.
mentioned above controlled by the command object is multi-threaded software code. Sometimes two threads will use the same macro command to run a series of commands. but we did not start the macro commands to be thread-safe problems. Therefore, When we began to experience strange thread safety problems caused, we must reconsider our implementation. The problem is that we should take the time to construct macros thread safe? or there is no easier way to solve this problem? < br> We use a more simple way to solve this problem and avoid over-design: for each thread to provide a separate instance of the macro command.
we can achieve this within 30 seconds solution. please take this time design of a thread-safe macros comparison of the time required to do.
This example illustrates how to use XP mode philosophical case to keep things simple. Without this simplification drive, over-engineered solutions mm thread-safe as it is prone to macro mm.
Therefore, the relationship between simplicity and model is very important.
When programmers need to make design decisions, a very important thing : They should try to keep the design simple, because simple designs are usually large and complex design than the easier to maintain and extend. we already know, reconstruction means that we remain in a simple way: it encourages us to a small and simple steps to gradually improve our design, and avoid over-design.
but the model? not they do not help us to keep it simple?
some would say design. They think that pattern will cause a rapid increase in the object, and lead to excessive reliance on object composition.
this view is the method due to errors in usage patterns to understand. experienced model user will avoid complex design, rapid object combination of growth and too many objects.
In fact, when using the model, the model user experience design make them easier. I will re-use an example to illustrate my point.
JUnit is a simple and useful J AVA testing framework, and its author is Kent Beck and Erich Gamma. This is a wonderful software, which is full of carefully selected a simple model.
recently some people asked me to be DeGo JUnit ? F, that is, the JUnit design pattern removed in order to observe the pattern of JUnit is not what it was like. This is a very interesting exercise, because it allows participants to give serious consideration should be introduced in the system when mode.
to describe what they have learned, we will JUnit 2.1 version of some of the extensions DeGo? F.
JUnit Test Case in a abstract class called, all test classes derive from the specific it. TestCase? class does not provide any way to run multiple times, also did not provide in its own thread and testing methods. Erich and Kent is very elegant with the Decorator pattern can repeat the test and achieve the thread-based testing. However, if the design team does not know Decorator pattern? Let us see what they will develop and assess how their design is simple.

No comments:

Post a Comment