Software design philosophy: Chapter XI twice design

table of Contents

Design software is difficult, so your initial thoughts on how to build a module or system is less likely to produce the best design. If you're considering a number of options for each major design decisions, you will get a better result: design twice .

You're assuming that category for the design management GUI text file text editor. The first step is to define an interface class will be presented to the rest of the editor; their choice idea first comes to mind, it is better to consider several possibilities. One option is for line interface, it has an insert, modify, and delete the entire line of text. Another option is based on a single character insertion and deletion of interfaces. A third option is a string-oriented interface, any range of characters that can be cross-bank operation. You do not need to determine each property of each option; at this point, and sketched out some of the most important ways is sufficient.

Try to select those methods very different from each other, so that you will learn more. Even if you only determine a reasonable approach, no matter how bad you think the second design, we must consider the second design. Reflections on the design weaknesses and compares it with other design features would be helpful.

After you sketch out alternative design, lists the advantages and disadvantages of each option. The most important consideration is ease of use for high-level interface to the software. In the example above, the line-oriented interface and a character-oriented interface requires extra work in the use of text class software. During the operation of a plurality of rows and row portions (e.g., cut and paste selection), a line-oriented interface will require a higher level software and is connected to the divided lines. Character-oriented interface would require a modified cycle operation is implemented a plurality of characters. It is also worth considering other factors:

  • An alternative to the interface is simpler than another? In the text example, all text interfaces are relatively simple.
  • An interface is more versatile than the other interfaces it?
  • An interface is able to be more effective than another interface? In the text example, character-oriented approach may be much slower than other methods because it requires calling text module separately for each character.

Once you compare the different designs, you can better determine the best design . The best option might be an alternative, or you may find that you can combine the functions of several alternatives to a better choice than any of the original new designs.

Sometimes, not an option particularly attractive, when this happens, see if you can propose other options. Use your problem identified in the initial alternative to drive new design. If you are designing a text type, and consider only the character-oriented approach and line-oriented, you may notice that each of the alternative methods are very awkward, because it requires a higher level of software to perform additional text manipulation. This is a dangerous signal: if there is a class text, it should handle all text manipulation. In order to eliminate additional text, the text interface needs to more closely match the operation takes place in the advanced software. These operations do not always correspond to a single character or a single row. This line of reasoning should provide scope for the text-oriented API, thus eliminating the problem of earlier designs.

Two design principles can be applied to many levels of the system. For the module, you can first use this method to select the interface, as described above. Then you can apply the design to achieve it again: For text type, you can consider such as row chain, to achieve a fixed-size character blocks or "gap buffer zone" and the like. "Objectives and implementation of the interface is different: to achieve, the most important thing is the simplicity and performance is also useful to explore a variety of design at a higher level system, such as when to select features for the user interface. or when the main system is decomposed into modules. in each case, if you can compare several alternatives, it is easy to determine the best method.

Two designs do not need to spend a lot of extra time. For smaller modules (e.g. classes), you may not need more than twelve hours of time to consider alternatives. Compared with the time you will spend days or weeks to implement this class, this is only a fraction of the time. The original design of the experiment is likely to produce a better design than it took twice the time to design much better. For larger module, you will spend in the initial design exploration more time, but will take longer to achieve, and the benefits of better design will be greater.

I noticed that "twice design" principle is sometimes difficult to be accepted by really smart people. When they grow up, wise men find their first thoughts on any issue quickly enough to get a good result; there is no need to consider the second or third possibility. It's easy to develop bad work habits. However, with the growth of these people age, they would be promoted to the increasingly difficult environment. In the end, everyone will reach a critical point, your first thought is no longer good enough; if you want to get really good results, you may have to consider the second, or third, no matter how smart you are. Design of large software systems fall into this category: No one has enough capacity to put it right on the first try.

Unfortunately, I often see smart people insist on the implementation of the first idea that comes to mind, which does not cause them to play out their true potential (which also makes them feel frustrated at work). Maybe they subconsciously believe that "smart people can be successful the first time," so if they try a variety of design, it means they do not wise. But in fact, it's not. This is not to say that you are not smart, the problem is really hard. Also, this is a good thing: to solve a need to think carefully about the problem than to solve a simple problem do not need to think much more interesting.

Two methods designed to not only improve your design, but also improve your design capabilities. Process design and compare various methods will teach you to make the design better or worse factor. Over time, this will make it easier to exclude bad design, and focus on what really great design.

Guess you like

Origin www.cnblogs.com/peida/p/12078980.html