We need to develop Object-Oriented Programming habits

Source: Internet
Author: User


the advantage of object-oriented is that it makes your Code More semantic, because it can intuitively Express "who. the semantics of what () "makes our Program code closer to the natural language. However, in reality,
we often see that process-oriented code is written using the object-oriented programming language . In fact, this is not hard to understand because most people start to learn programming languages from process-oriented linguistics, such as
basic, C, and other classical programming entry-level languages. However, in actual development, these process-oriented knowledge and experience have played a leading role for us, on the other hand, we hope to
be able to get the advantages of Surface object programming. In the end, what we actually produce is that there is no forward process or object-oriented code. Although we feel that there is a problem with the design, we don't know where the problem is. Later, we learned the OO design
principle and the OO design pattern and began learning like a treasure, however, in the process of learning, we often do not focus on the analysis and design methods described in the book, but on the code. So that the process-oriented and object-oriented systems are always stuck between the
process-oriented and object-oriented systems.

Therefore, in the actual coding process, we should develop good Object-Oriented Programming habits, look at the problem from an object's perspective, and describe the problem in an object-oriented way, avoid falling into the process-oriented mindset. When we need a function, the first thing we think of is behavior in OO, rather than process-oriented functions. An action must be initiated by a subject, which is an object. Just as we cannot find two identical things in the real world, objects can also be distinguished in the current problem domain. Ensure the integrity and uniqueness of objects to ensure that objects can be differentiated. We need to separate the object design process and implementation process, because we should consider what the object can do and what kind of API is required to provide external services, that is, the object interface. In this way, we can implement interface-oriented programming. The method name should be named based on what it is, rather than the method. We only need to consider how to implement it. These Implementation Details are encapsulated in the object. Several internal methods may jointly complete an API function. Of course, these internal methods are private methods in object-oriented programming. In addition, keeping an eye on the objects around us also helps cultivate good Object-Oriented Programming habits.


In JavaScript programming, programmers with different backgrounds implement OO in different ways. The implementation style of C # may be similar to C #. Typical examples include ASP. NET.
Ajax class library. The implementation style of Python may be similar to that of Python. In their programs, keywords such as _ init _ and sleft are often seen. So often
It is often questioned whether object-oriented programming should be used for JavaScript. In fact, the key to object-oriented thinking is not syntax. For example, Python and PHP are both object-oriented.
But their oo syntax is different. Therefore, we use the syntax standards of other languages to measure javascrui.
Is unreasonable. Simply put, I think that as long as the UML diagram obtained through analysis can be expressed as a program, it should be an object-oriented language.

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.