New perspective for object-oriented design

xiaoxiao2021-03-06  113

Alan Shalloway is the founder and president of Net Objectives. Since 1981, it provides for object-oriented and software-oriented guidance and training, such as Attachmate, Avaya, Boeing, IBM, Microsoft, Phillips Medical Systems, Price Waterhouse Coops, QWest. Wait, ALAN's research includes: Design Patterns, Java, C , XML, XP and Agile Software Development. His book "Design Patterns Explained: A New Perspective On Object-Oriented Design" is about to be issued, by transparent (gigix) translation) is "design mode" John Vlissides is called the best Design mode entry book. Alan has a master's degree in computer science in MIT. The following is the exchange record. Translation from gigix.

Mode matrix

Gigix: Recently, you have become a XPER, is it? What is your favorite method for your favorite?

Shalloway: Scrum also has a lot of wonderful ideas.

GIGIX: Do you still like the pattern matrix?

SHALLOWAY: I am rewrite the mode matrix, I intend to expand it again.

GIGIX: How do you see the mode matrix now? Use the mode matrix to do pre-design, is this good way? Shalloway: Mode matrix is ​​a good tool for learning mode. I think it is the main advantage is that it can be used to compare and compare between patterns. The study of the pattern matrix is ​​still in progress. In addition, I think pre-design and gradual design are necessary. When you are very familiar with the problem, you can leave the extended space in the pre-design. However, the expanded space cannot stay too much, we don't want to achieve unwanted things. On the other hand, I appreciate the principle of "simple" in XP. Do not achieve anything unless you need it. My principle is:

1. Test priority (and guarantee the automation of the test);

2. Effectively follow the principle of loose coupling, high polymerization, no redundant, with code to indicate your intentions.

GIGIX: I think the mode matrix and agile method are conflict, is it?

Shalloway: Why do you think so?

GIGIX: Because it advocates usage mode pre-design.

Shalloway: Let me explain: Maybe XP does say "Don't do any design in advance", but other agile methods will usually do not. The basis of agile methods is an iterative development. At least once a day, often listen to customer feedback, emphasis on people's value, automation test, and timely reconstruction. "Do not pre-design" and "pair programming" are XP practices, but not all agile methods practices. I don't believe that as long as the mode is used, it will cause overall design. However, don't want to use the pattern. This mode can only be applied only when you see the status of the problem and a certain pattern. I often hear people asked: "Where is my Strategies?" This is misuse mode: When you only have a hammer in your hand, you want to treat all the questions as nails. The mode is actually the association between things. For example, the Strategy mode describes the association between "things that may use different rules". The pattern taught us a new perspective of seeing the problem.

Design Patterns

XLP223: Do you think novices should learn from what models?

SHALLOWAY: Getting Started: Strategy, Abstract Factory, Composite, Bridge, Factory Method, Proxy, Decorator, Observer, Iterator, Adaptor, Facade, and Template Method. Even if you don't need them to design, these modes include the concept of developers to know. GIGIX: Do you have an article published by Joshua Kerievsky on SDMAGAZINE? He believes that the model is easy to cause over-work. Shalloway: Only when you use the wrong mode, they will cause over-project. Unfortunately, most people will use the wrong. However, as I often say - mode is used to describe the association of things in the field. As long as we don't want to be fictional, some things do not exist, the model will not hurt us. Crystal_Y: A large number of domains knowledge → tend to design in advance → maybe too project, when is it? To know "When to stop", what do we need? Experience? More domain knowledge? More computer scientific knowledge? Shalloway: When designed in advance, you only need to show the concept of problems, you can do not worry about specific implementation methods. Agile method will force you to do this because it requires you to achieve a certain number of functions within a certain period of time. Crystal_y: The domain knowledge can help us better understand the problem, and the model can help us understand the abstraction of the problem. Agility methods can help us get feedback faster to improve our understanding. right? SHALLOWAY: In fact, the mode will tell us from the perspective of analysis, design, and implementation. For example, in the analysis phase, I may find that I have several different documents that need to support different output devices. So, I see that there is text, pictures in the system ... They use laser printers, plotters, dot matrix, and so on as an output device. This is the scene of Bridge mode. So, I can define the problem area with an abstraction (different document types), and then give it different implementations (dot matrix, plotter, etc.). Now I don't have to worry about how to implement, because I am very grasped by Bridge mode. Requirements faster, make you resorted to the development process, because you can't wait for a complete demand, you can't want to do a complete system design, you can't do all the coding work and then test. XLP223: About mode benefits, you have already talked a lot. I want to know, what defect do you think of design mode?

Shalloway: I want to design the biggest problem is "design" words, which make people feel that the mode is about design. In fact, the mode is not limited to the design phase, which is called "design mode" because Gamma's research is mainly a reused design. There are related patterns in the analysis phase and implementation.

Object-oriented design

Zergo: Can you tell me some principles when designing objects?

Shalloway: The object is a responsible thing. They are responsible for themselves. You are talking to them through interfaces. You only manage them "what to do", don't worry about them "how to do".

YHUFO: The interface of the class is always more difficult to design. Can you tell me some skills for interface design?

Shalloway: When you design the interface, don't just think about the situation in your hand, you still think that the current situation may change, this is very important. However, in order to maintain the agility of the development process, do not do unnecessary extensions on the interface when considering other situations. However, sometimes through the future needs, you can get a relatively universal solution. CHARITY_Zhou: How do you think about the relationship between the reuse and complexity in the software design?

Shalloway: There is a bad tendency in object-oriented design: forced can be copied from the beginning. This is not a good idea, but we often do this. We have considerable emphasis when we design superclars, and then cover superclasses in subclasses when they need to change. The problem is that this often causes coupling between the unrelated concepts. For example, suppose you want to create a sales order system, you use superclars to express similar concepts (taxes, freight, etc. "fees") and then distinguish them in subclasses. As a result, you have a coupling between taxes and fees. This is not a problem in a period of time, but it will finally have problems. It will make your system difficult to understand. In programming, we need to pay attention to loose coupling (to avoid side effects) and high-polyset (in order to make code clearly), avoid redundancy (for efficiency). We are able to grasp the complexity of yourself - put them behind the interface or abstract class. For things that have emerged in the field, we should ask yourself: Is it a specific way to do something? Still do a universal method for a certain type? This book tells how we look for things that may change, how to pack changes: to find universal concepts, define the interface for the universal concept, let customers call the interface; for a particular method, implement the universal interface. GIGIX: I think the principle of object-oriented design (for example, open-closed principles) is more important than specific modes, is it?

Shalloway: I agree. Mode is just a specific solution. However, XP believes: Do not manage OCP (open-closed principles).

GIGIX:? If you don't follow the OCP, how to ensure the quality of the code?

Shalloway: You can't write the code that never modify, and this is the target of OCP. However, please ask yourself, why should I avoid modifying the code? Of course, there will be a lot of reasons. For example, a lot of code is very fragile - if you have modified a place, it will destroy another place. However, if you think about reducing the degree of coupling of the code, then modifications will not cause side effects. You may find another reason: if I have modified the code, you must re-test. However, if you are ready for automation test, the price of the system test will not be very high. Software developers have circulated a statement: we have used a lot of time to fix the error. is it? How many people think so? Think about your hardest problem, the hardest mistake. Now, think about how long you have used to find the error in your code? If the code structure is good, how much time can you save? How much is it to save? Anyway, most of the time is not consumed above. The wrong repair time is relatively small, and the time required to find errors is much more.

GIGIX: Agree.

SHALLOWAY: In the 1980s, I used half of the code time (10% of all times) to a system I wrote. At that time, my coding skills were still very immature, there are many coupling in the code, and the degree of cohesive is not good. This is a good experience. GIGIX: Then it is definitely difficult to maintain. Shalloway: right. If there is no strong internal gather, coupling is close, the test is small, so the system is really difficult to maintain.

GIGIX: I have a problem. In OOD, which principles are most important?

Shalloway: I can't say which principles are "most important", but I can list some important principles. You should regard the object as a definition of good responsibility; the object should be responsible for yourself; package is a form of hidden: hidden data, implementation or class; make the coupling between things (loose coupling); each method One thing, only one thing; class only contains related methods; avoid redundancy.

Outmyth: How do I achieve this goal of "low coupling"?

Shalloway: "Low Coupling" means that you have to define your interface: let the calling object you can send all the information you need for the service object. Private data and private methods may be helpful.

Crystal_Y: Abstract, common / change point analysis, is these to get a loose core?

Shalloway: These things can help you look at the problem in a better way. If you have programmed this, then you have much less. When designing interface, you only need to consider how to express the commonality between things.

AgileMind: What is appropriate, loosely coupled design pattern, can you tell me?

Shalloway: Loined things can change without causing side effects, nor does it cause many code modifications.

Agility method and XP

Leohoo: What is the difference between agile methods and XP, can you tell me?

Shalloway: XP is a agile process. It has four worth: courage, simple, honesty and communication. It has 12 practices. It is a method for agile development. Of course, there are other agile methods, Scrum is very good. Even RUP, you can also use it according to agile methods. Agility is a way, it thinks you can't know all the needs at first, at least in most projects. If you can know all the needs in advance, you don't need agile methods. SIMAETIN: "Honest"? Or "feedback"?

Shalloway: "Honest" is a value of XP, "feedback" is what you need. All agile methods require as much as possible to listen to the feedback, so you should do less early preparation. The less preparations, the more you can see some prototype products, and get feedback. Of course, everyone should pay the value of XP according to their needs. I personally, I don't necessarily start from XP. I will start from these practices: preparatory automation test, build, iterate every day. Maybe Scrum will be more easily implemented. However, if you like to be paired - then do it. I feel that it is very good to program, but some people don't like it, this is because Americans advocate the western cowboy individual heroism. Flyingsaucer: Some people say that XP is suitable for experienced developers, not suitable for newbies, what do you think?

SHALLOWAY: I think that some advanced developers do need in XP projects. However, any projects without senior developers will definitely encounter trouble. If there is no good coding skill, continuous reconstruction will make people feel uncomfortable, but if you use XP, at least you just need to let the developers know what you have to do, and the other half can sit first Learn. Other Technology Flyingsaucer: Mr. Shalloway, how do you see AOP (Aspect-Oriented-Programming)? What will its future development? SHALLOWAY: I have not studied. However, some respectable people say it is very good. If there is time, I will learn more.

SINBA72: Can you recommend a good UML book? I am an UML's beginner.

Shalloway: Martin Fowler's UML DISTILED is not bad.

PPLOVE.SHAO: Can you tell me some OR mapping mode?

SHALLOWAY: I have never studied or mapping, but I can tell you where to find these information. Scott Ambler has done a lot of research, but it has not been completed, you can go to www.ronin-intl.com to see. In addition, he is also famous, you can search for Yahoo!. Cajan2: Can you tell me how to apply mode in real-time system?

Shalloway: With a real-time system, I don't have much experience. However, about this theme, the best book is Schmidt's Pattern Oriented Software Architecture Volume 2.

BANQ: How many design patterns in EJB?

Shalloway: There is a good book on EJB mode: EJB Design Patterns. Unfortunately, I know that this book is only an English version. The reason why EJB is useful because we can put a specific function into an object by EJB, and then don't worry about things in the living cycle, storage. Even if EJB is not used, these design ideas are also very important.

bid farewell

SHALLOWAY: I have to declare: I am attending today's communication, not just to promote our book, but also because I may go to China to train. I hope someone can help me arrange to China's itinerary. If you can help, please contact me: Alshall@NetObjectives.com. GIGIX: Welcome to China.

Shalloway: The night is already very deep. I am very happy to communicate with you today. I hope that there will be such a activity in a few months. Goodbye, you. Thanks to Umlchina hosted today's exchange. Thanks to everyone's participation. Cajan2: Mr. Shalloway, I am very happy to communicate with you today. Goodbye.

Note:

Pattern Matrix is ​​an analysis and design method that Alan Shalloway is proposed in Design Patternal Explain. The value in XP is indeed "Feedback" instead of "honesty", Mr. Shalloway may memorize. The primary developers can learn from the group's senior developers and try to make their own contributions.

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

New Post(0)