Object-Oriented Design = virtual function design?

Source: Internet
Author: User

People often talk about "object-oriented design", as if it is something highly advanced and proud of object-oriented design. Object-oriented, not necessarily applicable to all occasions. For example, for the underlying communication module, it is not necessary to use object-oriented.

But what kind of design is object-oriented? Is it because you only need to use the class, and how many member functions and member variables in it become object-oriented? Of course not.

Object-oriented. I have summarized it into two aspects. One is "God" and the other is "shape ". Only designs with both shapes and gods can be called real object-oriented design.

The so-called "God" refers to the ability to construct a system based on the object's thinking in system planning. For example, in a banking system, you cannot divide the system based on functions such as saving money, taking money, and checking accounts. Instead, you should use "bank accounts ", "user" and so on to divide the objects that constitute the banking system, and then add data and functions to these objects. That is to say, to be object-oriented, we should first cultivate a way of thinking that focuses on "objects and classes", that is, taking data as the center rather than process as the center.

The so-called "shape" refers to some typical object-oriented design techniques used in object-oriented design, so that people can see that they are object-oriented. Among these techniques, the most attractive thing is "virtual functions. Looking at the books on various design patterns, in the end, they all use inheritance and Polymorphism to the extreme, and virtual functions are an essential design method to implement many models. Therefore, some people may say that "object-oriented design = virtual function design" is not completely correct, but this is really a rumor.

A little bit of sentiment, you look at the official, right to laugh! Haha.

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.