King and electric oven
Once, in a kingdom, a kingdom not far from here, the king called his two consultants and let them look at a sparkling metal box. There are two openings on the top, and there is a knob and a handle next to it.
"Do you know what this is?" Asked the king.
A consultant - he is an engineer - first reply: "It is a electric oven."
The king then asked: "How will you design if you design an embedded computer?"
The engineer replied: "Use a 4-bit microprocessor. I compile a simple program, read the current position of the Fire Regulation knob, quantify the position information, and become one of the 16 cola levels of the bucket to the dark. Program In the focus level, the preset barbecue time is read from a 16-line small data table. Then, the program start the heater, set the barbecue time in the timer, turn off the heater after the timer is completed. , Pop-ups. Give me a week, I can take out the prototype of this program. "
The second consultant is a computer scientist, and he immediately realizes the idea of engineers is a lack of vision. He said: "The electric oven is not just used to get into toast. It can also be used to heat the egg cake. The actual breakfast machine is actually a breakfast machine. Our national life experience, they need multi-function For example, a breakfast machine that can roast sausage, fried root, scrambled eggs. Only when we can get out of the electric oven, if we don't think about it, it must be two or three years later. Design the electric oven.
"In view of this, we can define our electric oven. First, create a class named breakfast. Then, a group of subclasses are derived from this class: pasta, meat, poultry, etc. Face Further derivation of bread, muffin, pancakes, egg cookies; meat derived from sausage, meat, bacon, poultry, boiled eggs, poached eggs, fried eggs Class and a wide variety of eggs.
"For cheese ham omelet, it needs special treatment, it must inherit the characteristics of meat, dairy products and poultry. Therefore, there is no way to solve this problem without multiple inheritance. Operation, the program must be correct Create an object instance, then send a message to the object 'to work yourself. What kind of operation will cause the message to depends on the type of object, so that the same message can activate all kinds of different operations from the toast to the scrambled eggs. .
"In summary, in the analysis phase, we will define core needs to process different kinds of breakfast foods. In the design phase, we will further clarify the additional demand for this derived. For example, we must use a multiple inheritance function Object-oriented language. In addition, the eggs have been cool, and the bacon has not yet baked. Therefore, it is also necessary for multi-task concurrent processing.
"Don't forget the user interface. The handle is not suitable for processing a variety of food. The fire adjustment knob is easy to touch. Users will only buy products with friendly graphics interfaces. When breakfast machines are inserted Users will see a shif gun on the screen. Click to send a gun, after a gun launches, the word "starting Unix V.88.33 '" will appear on the screen (UNIX V.88.33 will be released before the breakfast machine is available). Users can open the drop-down menu, click on the food name they want to process in the menu.
"In the previous design phase, we define the functionality of the software, the next thing is to choose a suitable hardware platform for the implementation phase. Recommended hardware configuration is Pentium 4 2.6G CPU, 2G memory, 160g hard disk , 21 inch LCD display. In the software, if you choose a multi-task, support multiple inheritance, there is an object-oriented language of the built-in GUI development package, then you will be more relaxed when you write a program. - In contrast, The first to determine the hardware environment, how stupid it is to imprison himself on the 4-bit microprocessor! "The king wisely cut off the head of computer scientists. Since then, the kings and their nationals have always lived very happy.