Object-oriented notes OOP

Process-oriented & object
-oriented process - oriented thinking The
steps are clear and simple. What to do in the first step and what to do in the second step
Process-oriented is suitable for dealing with some simpler problems.
Object-oriented thinking is
clustered and classified. Thinking about problems will first solve problems. Need those categories, and then think about these categories individually, and finally, do a process
-oriented thinking about the details of a certain category. Object-oriented is suitable for dealing with complex problems and suitable for dealing with problems that require multi-person collaboration.

For describing complex affairs, in order to grasp at the macro level and analyze the whole system reasonably, we need to use object-oriented thinking to analyze the entire system, but specific to micro-operations, we still need process-oriented thinking to deal with

What is object
-oriented? Object
-oriented programming The essence of object - oriented programming is to organize code in the way of classes, and organize (encapsulate) data by objects.
From the perspective of code operation, there are classes before objects. Classes are template
classes and objects of objects. The relationship
class is an abstract data type. It is an overall description/definition of a certain type of thing, but it cannot represent a specific thing. The
object is a concrete instance of
an abstract concept. The three major characteristics of object-oriented
encapsulate
our design program design requirements. The pursuit of "high cohesion, low coupling" high cohesion means that the internal operation details of the class are done by themselves, no external interference is allowed, low coupling: only a small number of methods are exposed for external use.
Encapsulation (data hiding)
Generally, direct access to one should be prohibited The actual representation of the data in the object, but should be accessed through the operating interface, which is called information hiding

Property private, get/set
inheritance
. The essence of inheritance is the abstract
extends of a certain batch of classes. It means extension. The subclass is the extension of the parent class. In
Java, classes have only single inheritance, and there is no multiple inheritance
. Kind of relationship. In addition, the relationship between the class and the class
has two classes of inheritance relations such as dependency, composition, aggregation, etc. One is a subclass (derived class) and the other is a parent class (base class). The subclass inherits the parent class, and the keyword extends is used to indicate the
relationship between the subclass and the parent class. In the sense, there should be a
polymorphism of "is a". The
same method can adopt a variety of different behaviors according to the different sending objects.
The actual type of an object is determined, but there are many types of references that can point to the object

Conditions for polymorphism There is
an inheritance relationship The
subclass overrides the parent class method The
parent class reference points to the subclass object

Note: Polymorphism is the polymorphism of the method, there is no polymorphism in the attribute

Inner class
◆Inner class is to define a class inside a class. For example, define a class B in class A, then class B is
called internal class relative to class A, and class A is external relative to class B Class now.
1. Member inner class
◆ 2. Static inner class
◆ 3. Local inner class
◆ 4. Anonymous inner class

Guess you like

Origin blog.csdn.net/m0_46937429/article/details/113178768