[Java Interview] Talk about your understanding of object-oriented?

Interviewer: Tell me about your understanding of object-oriented?

Me: Well, first of all, object-oriented programming (OOP, Object Oriented Programming) is a programming idea or a programming architecture, which guides our design principles in programming. Talking about object-oriented, we can combine it with process-oriented: process-oriented programming emphasizes the process. For example, if we want to design a program that puts an elephant in the refrigerator, process-oriented requires us to think about the execution process of this program, and then implement Every step in this process, and object-oriented emphasis is on objects. When solving this problem with object-oriented thinking, we think about which objects can be abstracted in this program, what characteristics (attributes and methods) each object has, and their How to complete a job in cooperation with each other reflects the object-oriented abstract principle. Of course, the object-oriented principle also includes encapsulation, inheritance and polymorphism. Encapsulation refers to encapsulating the properties of each object without Allow the outside to obtain or operate directly, but let the outside operate by exposing some methods to the outside. Inheritance means: for example, if there is more than one animal like an elephant, the animal class can be further abstracted, and then the elephant, Squirrels and giraffes inherit from the animal class. The inheritance principle provides good code reusability, reduces redundant code, and makes the code more concise; polymorphism means that when the parent class reference points to the subclass object, the parent class calls in the subclass The method overridden in will behave differently depending on the subclass object. So why is it so complicated? I feel that process-oriented programming is more concise, clear and easy to understand. Indeed, in the early days of programming development, there was no object-oriented. Process-oriented programming is concise and efficient, but with the development of software systems, Business and functions are becoming more and more complex, and the process-oriented design method begins to show disadvantages. It often needs to continuously reinvent the wheel, so object-oriented came into being. Its appearance has achieved the three main goals of software engineering: reusability, flexibility It is more suitable for modern complex and software program design, and it is more suitable for process-oriented programming in areas that have higher requirements for program operation efficiency and less complex programs, such as single-chip microcomputer design. object understanding.
insert image description here

Guess you like

Origin blog.csdn.net/huhuhutony/article/details/120810865