What level is your object-oriented technology?

Source: Internet
Author: User
What level is your object-oriented technology?

How to master OOP

1. Link object-oriented objects with the object abstraction of specific languages

At the beginning of object-oriented technology, it seems useless to add a great theoretical explanation, what principles, methods, and so on. The only object that can be understood is the class. When programming, a noun is used to write it into a class, so that this is object-oriented programming. Taking the library case as an example, after preliminary analysis, student may be used as our class for programming and its attributes, methods, and operations are designed, specifically, student is added with the name attribute and the method of borrowing books.

It seems that object-oriented technology is so simple. At this time, we will doubt what encapsulation, polymorphism, inheritance, and so on at the beginning of the object-oriented language book will play a role in the end. This is just a lot of nonsense !?

At this time, if we look at the implementation of the Javascript object-oriented technology, it is simply because of Hell, suddenly there is a feeling of being cheated, the original object can not only be expressed in class, ah, there are other implementation methods.

2. Apply object-oriented methods to programming

After continuous programming practices, martial arts have gone from chaos to tactics. Taking the library as an example, we found that student has the method of borrowing books, and teacher also has the method of borrowing books. As a result, student and teacher both have the function of borrowing books. At this time, our object-oriented methods include encapsulation, polymorphism, inheritance, and so on. Let's make it simple. Both teacher and student can inherit from the reader class, while reader designs the borrow method.

At this stage, we found that the original object-oriented method encapsulation, inheritance, polymorphism, and so on are still useful. However, the terms encapsulation, inheritance, and polymorphism are too abstract. If there is a specific user guide or can there be a martial arts method that summarizes these methods?

3. Available Design Patterns

Do you have any martial arts skills. We have prepared a superior Martial Arts secret-design model for our predecessors. The design model is comparable to the secret of martial arts using knives, guns, and swords. The design model, a martial arts routine, can flexibly use the object technology to clarify the relationship, structure, behavior, and collaboration between objects.

At this time, the question came up. The design model master gave Jin yuliang a saying, "Use combination first. Do not move and use inheritance ". My heart will not only be chilling, but the master gave me the power of mind and finally left me a trick.

4. Understand what the essence is

When we use object-oriented technology, we use the class concept to use the internal structure and behavior to design and implement the computing logic.

There are many times when we cannot accurately grasp the essence of a thing, it may be simply looking at the problem from a perspective. Now that we have read from the inside, we can observe things from the external perspective. The object has its own environment, and the division of labor and cooperation in the environment is like in our real society, between people, and between nature, there is a division of labor and collaboration, harmonious coexistence.

The topic is far away, and we will go back to our program world. If one day we want to do something in the community and watch a movie in the cinema, We can abstract it and create a model, when we go to the Community to do things and watch movies in cinemas, we enjoy services. By abstracting the providers of these services into the program world, we can use classes to express actions such as serving affairs and watching movies at the same time. Community Services, cinema and movie watching are two different things which can be abstracted into two objects that provide different services in the program world. From the perspective of contract, any object that implements these services must fulfill the service contract. From the perspective of the object, we do not need to know the internal content of these objects, that is, to do things, the key to watching a movie is not to know where to solve these problems, but to provide me with services for the purpose.

Imagine one day when I went to a movie, I could solve the problem of Community Affairs. In this case, we cannot simply express and think with the abstract thing "class". Another thing that is not explicitly mentioned in the design pattern is that there are almost two layers in each pattern, one is the abstract level, and the other is the concrete level. To put it bluntly, there is another interface on the object. There is no difference between the interface and abstract class. In this case, the super hero who can take actions and watch movies will be able to come into being, of course, during the analysis, we don't need to know exactly where this service is to be provided. We only need to design two interfaces: Service and movie watching, as for who will implement this service, I don't care.

5. flexible use of object-oriented technology in coding, design, analysis, and other fields

When we use object-oriented technology to solve specific problems, we will not be aware of this martial arts. The object-oriented technology has evolved from the basic understanding of object orientation into a class to the true meaning of object orientation in the real society. Everyone has a division of labor. We are also an object of the social system. We also need to provide external services. For example, I can be an encoding object. I specialize in converting program design into code. This is my service. However, optical coding objects do not work. We also need design objects to provide design services and analysis objects to provide analysis services. The technology industry has a specialization. The encoding object can be continuously learned and developed in depth or horizontally.

Summary

The outermost layer of object-oriented technology is the specific application of technology in coding, design, analysis, and other fields, followed by the level of object-oriented language. When beginners learn, they often enter from this level, it is easy to cause one-sided understanding. Then there is the martial arts routine of the design pattern. Although the routine is just a form, it is still very useful when the object-oriented needs to be improved, and can be used as a guide to action. The next layer is the object-oriented understanding, the use of solid principles, encapsulation, inheritance, polymorphism, and other methods.

What level is your object-oriented technology?

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.