It looks simple, actually complex

zhaozj2021-02-16  83

Author: Joel Spolsky Translation: Bo Yang translation

EDTOR: BILLY CHEN

March 4, 2002

We have a small problem in the cityDesk.

The problem is this: You can import a file from the Internet on the Internet on the menu. You can also import a file from the disk with a mouse to drag and drop. However, there is no "Import Disk File" command on the menu, so some users have not found CITYDESK with this feature, or they try to import files on the disk with the "Import Page" command, resulting in successful import.

I started thinking about this problem, and the approximate method is to import the wizard with a file of two pages. The first page ask you: "Where are you imported?". If you choose "Disk", the second page will prompt you to choose a file; if you choose "Internet", the second page will prompt you to enter a URL.

I almost started to do this, but some things make me don't do this. I decided to write a small statute. The statute written is as follows:

First page

Where do you want to import?

Disk / Internet

Page II (Disk)

Standard Open File Dialog

Page II (Internet)

Let you enter a URL with a small browser

Suddenly I thought of a question. Windows open file dialogs, usually provided by the operating system. Can you put this dialog box into my file import wizard?

Ok…

I checked it. It is possible to do this, but this is not a fun thing, and it takes a few hours. Can I not use the way of importing wizards? I renounced my statute:

Two menu items:

1) Import the web page from the Internet -> Display URL Enter dialog

2) Import the web page from disk -> Display Open File Dialog

This is much better. Three minutes design time saves me for a few hours of programming time.

If you spend more than twenty minutes above for more than 20 minutes, you may find a rule: things don't look so simple.

Just like a copy file is simple, it is full of danger. What is the first parameter is a directory? What is the second parameter is a file? What if the same name is existing in the target subdirectory? What will you do if you don't write?

What should I do if I fail during a copy file? What if the destination is on a remote computer, but what should I do if I need authentication? If the file is large but the network connection is slow, what do you need to display a progress bar? If the file transfer speed is almost zero, when do you give up a copy to give the user an error message?

A good way to interview testers is to give them a simple operation process and then let them list the possible error. A typical question at Microsoft Interview is: How do you test to open a file dialog? A good tester can easily list dozens of difficult situation to test (such as "a file is displayed in the dialog, then you go to open it, but before you press the button, this file Remove it by another user ").

Ok, we get such a axiom: things don't look so simple.

There is also a guiding ideology in the software engineering, that is, you have to think about it to reduce risk. A risk to be particularly careful, is the risk of project progress extension. The project is delayed is very bad, because the boss will train you, you are quite unhappy. In addition, this also has an economic reason, that is, when you decide to add a function to your software, you feel that this feature can be completed only for a week. Now that you realize that this feature is required for twenty weeks to complete, then you originally decided to be wrong. If you don't know how to get twenty weeks, you may make a different decision. The more you make a mistake, the larger the possibility of your company's property is handled by one-time crushing (or even your company's logo will be incorporated by the creditor's warehouse). At that time, your front boss complained: "Our company closed down, nothing, the gas is not eligible to fuckedcompany." Things have not seem to be so simple, plus reducing risk guidance ideas, only Let you get the following conclusion:

First design and then edify, and strive.

Let you be disappointed, I am sorry. I know that you have read Kent Beck's book, so you don't do design before you do it. Sorry, it is not possible. Your modification cannot be "easy" as modifying design files. Some people always publish such a paradox: "We now use advanced tools, like Java and XML. We can change a lot of things in the program within a few minutes. Why not design it directly in the program?" You can add an engine on your bicycle, but you can't turn it into a car. If you think the program that copies your copy file, it is changed from the line to a preemptive, and it is faster than I write this sentence, then you have a big mistake.

Anyway, I don't think Extreme Programming is a concept of advocating zero design. They just said: "Don't make anything unnecessary design", this is nothing wrong. But people hear is not the case. Most programmers are looking for excuses that do not need to be designed, so they are like a moth to swimming the "no design". This is a lazy way that is strange to make you feel more than half. I am too lazy to give this feature on the paper, so I will write the program first, then I found it wrong, I will change it, and the result is more time. Or, more often, I will write some programs first, find it is wrong, but there is no time to change, the quality of my product is poor, and I still have to find some excuses, explain why "must be like that." That is just a horse tible, lacks a career spirit. When Linus Torvalds attack, he is talking about the large system. The large-scale system must evolve slowly, or they become Multics. He is not talking about your copy file. You think about it again, there is a very clear road map in Linus Torvalds, know where he is going, so he feels nothing to design, and it is not surprising. But don't go up, basically say that it is not applicable to you. Linus Torvalds is much smart than we, so he can do things, it is not equal to our average person. The gradual design and implementation are good things. Frequent release is possible (but for software on the mass market, frequent release versions will make users unhappy, never a good idea - can do more within the milestones).). Don't stand in the form, it is just a waste of time. I have never seen a process for the flowchart, UML, CRC, or other fashionable, flower whistle design method. As for those of Linus Torvalds, those who have a thousand lines of code programs should slowly evolve, because humans don't know how to design the size of software. But when you sit down and write your copy file, or when you plan to add your software next version, you must first design. Don't let your journey make your grass. This article is first published in English, entitled Nothing is as Simple As It Seems

Joel Spolsky is a founder of a small software company in New York City, founder of Fog Creek Software. He graduated from Yale University, once in Microsoft, Viacom, Juno, Software Designers and Manages.

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

New Post(0)