On event-oriented design (EOD) and object-oriented design (OOD)

Source: Internet
Author: User
Putting these two concepts together is really not neat. But for those who are keen on design, we only need to use it.

First, we will explain these two concepts. What Is Oo? Haha, maybe everyone will laugh at me. Oo, who doesn't know? Don't talk to me about encapsulation/Inheritance/polymorphism! These are all so-called features. My question is: what is oo doing? For example, suppose you are a project manager. Now you have a task on hand that you need to complete. What will you do? One option is to complete all tasks by yourself. Of course, if you are willing to seize all your opportunities. You can do it. This is the process-oriented (OP) that we have often mentioned ). You know what you should do and you have done it. Of course, you will gradually find that your staff can help you solve some problems. So you tried to ask them to execute the tasks you arranged for them. However, you are not in the op stage. You are arranging all the work, planning, and thinking. You just used some ready-made libraries to help you work. Over time, your staff will gradually replace your work. You started to hand over the task to several people, telling them what you wanted and letting them do it. Conduct proper supervision and coordination during the process. Congratulations, you are using object-oriented. You no longer care about the details of the task. You are concerned about how to make your work happy, adjust your work status, give encouragement, stress, and encouragement. This is oo. Yes, oo is the way to handle the problem. Turn you from an unknowing sage into an uncapable idiot. Choosing op or Oo is just your character. Then, after explaining Oo, Let's explain the concept of "Event. What? Event? Isn't it a function type? Isn't it the previously failed function in windows? Isn't it a special type of pointer? Function pointer. Yes, I am not asking how events are implemented. I am asking, What is the event? Let's give you an analogy. For example, we need to complete a task. The content is from Beijing to Nanjing, 1000 kilometers away. We chose a vehicle and an expressway. That's good. You're starting to choose the car to drive. There are now ready-made cars of various brands on the market (these are all ready-made products provided by the Framework. If they are used, you do not need to implement the car type on your own ). Are you willing to choose? But now there is a very practical problem, the general fuel tank for a home car is only 50 litre, to run 1000 kilometers, the oil is definitely not enough. It seems that the average car cannot meet our needs. One way is to build a car by ourselves. The fuel tank is large enough to put 120 liters of oil. Obviously, the power system can meet the requirements. However, building a car requires a lot of professional knowledge. You cannot get through this path, so you can only switch to the original solution. Since one time is not enough, can you refuel? Of course! Now, we are talking about the concept of "Event. For those who want to complete the task, "events" are not our concern. People who really care about are people who design cars and highways. Well, now we have to make a tough change. You have changed from the person who completed the task (from Beijing to Nanjing) to the chief designer of the highway system. After changing the role, congratulations! Your design has improved your control capabilities. Suppose you have completed the conversion. You are the chief designer of the highway system. While designing the road, you must solve the problem of our fuel. But you don't know when we need to refuel. What should we do? First, it is necessary to design necessary gas stations on the highway, and then, more importantly, put forward signs on the road so that cars can receive information and know where there is a gas station. Back to the software, if you design a highway or a vehicle, the vehicle should trigger an event when receiving the gas station information on the highway. As for how to deal with it, it is the task completion, that is, the driver has to judge. First, check whether the oil is enough. If not, enter the station to refuel. With such a large circle, I just want to say that the event is a framework designer, allowing users to easily expand or customize their own behavior methods. The reason why I put EOD and OOD together is actually because the popular frameworks are both a combination of the two. Such as MFC, VCL, And. NET Framework. Recently, when discussing the eclipse architecture, we discussed the concept of "extension points" for its plug-ins. In fact, events are also the "extension points" used in the design ". Or you can say that EOD is an extension of Ood. Event is not unique to oo. It is an idea added on the basis of OO to solve the "Execution Process" problem. With this idea, these users can easily meet various needs. In the past, I heard the debate between op and OO, and the center is the idea dispute! In fact, we often use everything to solve the problem! At that time, we may find that it is good to solve problems without thinking. This also makes us more confident that the design has no boundaries!

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.