Design Pattern learning-Object-oriented Thinking

Source: Internet
Author: User


What Is Object-Oriented
When people are new to programming, most people may instinctively reflect process-oriented (OP) rather than object-oriented (OO. This phenomenon is actually quite normal. Changing the Way of Thinking requires a process. I have summarized the reasons for its formation:

1. Cause
You have not developed the habit of object-oriented analysis and problem solving. It takes some time to train and speculate on how to establish an object-oriented mindset. Therefore, you can deliberately strengthen this awareness in learning or in specific projects. Under normal circumstances, after a period of time, you will feel that this is a natural thing, only OO in your heart, naturally OO in your eyes.

2. Historical Reasons
We were trained from an early age to analyze and solve problems in the process-oriented (OP) approach, especially in mathematics. Most of the training focuses on solving problems step by step, the development of computer software has always been related to mathematics. Therefore, it is natural to bring the process-oriented (OP) method into software development.

What is object-oriented, or talk about your understanding of object-oriented, which may be the most common issue for software developers, especially programmers and designers. The corresponding English language of object-oriented is object-oriented, which translates object-oriented into "Object-Oriented". I always think this translation method is not accurate, for the first time, it is difficult for most people to understand the meaning of "Object-Oriented. Later, I checked some related information and found that the computer books in Hong Kong, Macao and Taiwan translated it into "object-oriented". I feel good about this translation method, in my heart, I am quite confused. "Object orientation" accurately reflects that object-oriented recognition and problem solving all focus on objects.

Therefore, the object-oriented thinking method holds that the software system is a set of interactive objects. A group of related objects are combined into a subsystem, and a group of subsystems are combined into more complex subsystems until they are combined into the entire system.

The starting point of the object-oriented approach is to simulate human habits as much as possible, and abstract the content involved in the "problem domain" into "object ", make software development methods and processes as close as possible to human understanding of the methods and processes of solving problems in the world. Process-oriented is to analyze the steps required to solve the problem, and then use functions to implement these steps Step by step. You can call these steps one by one. Object-oriented refers to dividing a problem transaction into various objects. The object is created not to complete a step, but to describe the behavior of a thing in the whole process of solving the problem.

The process-oriented thinking can be referred to as the process theory, which focuses on the process steps. The process is the core of the entire system.

Object-oriented thinking can be called Assembly theory. It focuses on the abstraction and extraction of objects, and then assembles objects into a whole.

Therefore, Oo and OP have completely different starting points in terms of their way of thinking.

OO believes that the software system is a set of interactive objects. Since humans are very familiar with the real world, oo maps the problem domains to the real world in an abstract way, and tries its best to simulate everything in the real world. In this way, you can use the solutions and processes in the real world to solve problems in the software field. Some people say that everything is an object in the eyes of OO. This sentence makes sense.

Example reference Original:


The idea of software engineering emerged to solve the software crisis. The reason for the software crisis was not that the program could not be written, but that the program could not be modified or run stably! Because society is making progress and the demand for software is constantly evolving, it requires our programs to change with the changing needs, and traditional methods cannot solve these problems. The emergence of object-oriented technology is to solve the problem of changes, so that the software can adapt to changes. For this change, the program needs to establish a more reasonable and stable structure, and the program will inevitably become more complex. However, this complexity is quite reasonable, because our real world itself has this complexity, object-oriented systems are still simulating the real world when implementing functions. Object-oriented software development is gradually developed in response to the software crisis. The object-oriented thinking makes the software easier to expand and maintain. During software development, coding is not the most important, and analysis and design are the most important. Therefore, a good idea or architecture is a guarantee to improve the quality of software.


My own perception: I think that when I was doing an internship at the time, I had to change from 3G front-end group 1.0 to 2.0. In fact, I used different ideas to reflect the same business, at the beginning, I used 1.0 to solve the problem in a process-oriented manner. As the demand changes, I deleted and modified the code in the main business. At that time, many old colleagues said that 1.0 of the Code was difficult to maintain, indeed, it is a headache to see the code. After all the functions are combined and changed, I don't know if it will affect it. At that time, the project team decided to use the idea of components to extract the same modules and then assemble them into a complete business, now I understand that the project manager said that 2.0 is the real object-oriented model. After receiving a requirement, we only need to modify the component. For example, the user test is a component, which is included in all the mobile account opening processes, this is extracted as an object, which achieves good reuse and expansion.


Insist that when you see every entity in your life, you can abstract its class and abstract all the interactions with it. The most important thing is to have a general picture, do not tangle with any details. In OO's thinking, the key is to grasp what can be done rather than how to do it. What can be done is the attributes (methods) of classes/objects ), how to do this is the implementation process of the method, which should be solved in the specific coding. You can write a method name that allows you to see the function at a glance, and then ignore it, after completing the overall framework design, fill up the methods one by one.




2. // Java beginners entry classic: Object-oriented Thinking Method

3. // Object-oriented thinking process

4. // view the object-oriented thinking mode from the problem of printing prime numbers


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: 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.