Basics - Object Oriented (OO - Object Oriented)

Four points of writing code:
     1. Identify needs. What to do?
     2. Analysis of ideas. How to do? (1,2,3...)
     3. Determine the steps. Which statements, methods, and objects to use for each idea.
     4. Code implementation. Realize ideas with specific language codes.

Four tips for learning new technologies:
     1. What is the technology?
     2. What are the characteristics of this technology? (use points that need attention)
     3. How is the technology used? (Write Demo)
     4. When will the technology be used? (Usage scenarios in Project)

---------------------- Plan early, prepare early, and finish early. -------------------------
To understand object orientation, you must first know what an object is.

object

     Objects are the mappings of entities such as people, things, and objects in the real world in computer logic.
     Objects have uniqueness, abstraction, inheritance, and polymorphism. Each object has its own unique identifier, through which the corresponding object can be found. In the entire life cycle of the object, its identifier will not change, and different objects cannot have the same identifier; abstraction means that the Objects with consistent attributes and behaviors are abstracted into classes, and a class is an object. Therefore, the abstraction of an object is a class, and the reification of a class is an object. It can also be said that an instance of a class is an object; inheritance is also a kind of between classes. Relationship is a mechanism for subclasses to automatically share data structures and methods of parent classes; polymorphism means that the same operation, function or process can act on multiple types of objects and obtain different results. Polymorphism enhances Software flexibility and reusability.
     Everything is an object, and an object is anything that people want to study, from the simplest integer to a complex airplane. Objects can represent not only concrete things, but also abstract rules, plans, and times. Objects have state and behavior. An object describes its state with data values ​​and changes its state with operations. Objects and their operations are the behavior of objects. The object realizes the combination of data and operation, so that the data and operation are encapsulated in the unity of the object.

Object Oriented (OO - Object Oriented)

      Object-oriented is an idea and a software development method. The object-oriented method is a systematic method that applies the object-oriented idea to the software development process and guides the development activities. Before the advent of object-oriented, computer programming was based on process-oriented, which emphasized functional behavior. Object-oriented is to encapsulate functions into objects, emphasizing objects with functions. Through the object-oriented method, things in the real world are abstracted into objects, and relationships in the real world are abstracted into classes and inheritance, helping people realize abstraction and digital modeling of the real world. Therefore, object-oriented is based on the concept of objects, with objects as the center, and classes and inheritance as the construction mechanism to recognize, understand, and describe the real world and to design and build corresponding software systems.

Three characteristics of object-oriented: encapsulation, inheritance, polymorphism

      1. Encapsulation: Only hide the attributes and implementation details of the object, and only provide public access to the outside world.
                    Benefits: Isolation of changes, ease of use, improved reusability, improved security;
                    Principle: Hide content that does not need to be provided externally, hide properties, and provide public methods to access them.
                    Note: Private is just a form of encapsulation.
      2. Inheritance: extends, there is a certain relationship between two things, and the inherited class can obtain some properties and methods from the inherited class, which improves the reusability of the code. Inheritance is a prerequisite for polymorphism. Inheritance is the most important feature of object-oriented programming language that is different from other languages, and it is not available in other languages.
                    Note: All constructors in the subclass will access the empty parameter constructor in the parent class by default. By default, the first line has super(); if there is no empty parameter constructor, it needs to be specified in the subclass; in addition, the subclass constructor In other constructors, you can use this to specify your own.
      3. Polymorphism: The various forms of existence of things. A reference variable defined by a parent class or interface can point to an instance object of a subclass or a concrete implementation class.
                    Benefits: Improve the scalability of the program;
                    Disadvantages: When the parent class reference points to the subclass object, although the scalability is improved, it can only access the methods in the parent class and cannot access the methods in the subclass; that is, the limitation of access.
                    Premise: Implement or inherit the relationship, overwrite the parent class method.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324830541&siteId=291194637