Author: Instructor Chen,Hua Qing vision embedded college lecturer.
1. Everything is an object. Think of an object as a strange variable, which can store data. In addition, you can also ask him to perform operations on himself. In theory, you can extract any conceptual component dog, building, service, etc. to solve the problem, and express it as an object in the program.
2. Programs are a collection of objects. They send messages to each other to tell each other what they want to do. To request an object to help you solve the problem, you must call the method defined by this object. The object will help you solve the problem through its own defined methods.
3. An object definition can contain another object or several objects.
4. Each object has its own type. "Every object is an instance of a class ). Here the class, and type, category is a meaning.
5. All objects of a specific type can receive the same message. Or, objects in the same class can call the same method to solve the problem.
Object-Oriented Programming is actually creating a new data type. All programming languages facing objects use the Class keyword to represent the data type. Because a class is a set of objects that describe data elements with the same features) and behavior functions. Here, programmers can customize data types and the programming system helps you maintain custom data types. When developing a program, one of the best ways is to think of the object as a "service provider", and the program itself will provide services to users by calling the services provided by other objects. In a good object-oriented design, every object can be used to accomplish a task well, but it does not try to do more. That is to say, its functions are as single as possible to improve cohesion.
Oop believes that a program is composed of objects that have their own properties and can perform operations. Then, whether to construct an object by yourself or use a constructed object depends on the budget and time. However, basically, as long as an object can meet its needs, it does not have to worry about how its functions are implemented. In oop, you only need to care about the appearance of the object, just as the computer manufacturer only cares about whether the power supply meets the requirements, rather than the internal implementation principle of the power supply, the vast majority of java Programmers don't have to worry about the specific implementation process of objects, as long as the objects meet their needs.
The key to oop is to let every object be responsible for executing a set of related tasks. If an object depends on the task of another object, it accesses the object containing the task. In this case, the first object requests the second object to execute the task. This kind of work is actually implemented by the process call that people are familiar with in the process design, namely the call function, and the call method in java ).
It must be noted that an object can neither directly access the data inside another object nor allow other objects to access its own internal data. Communication between objects is implemented through method calls. By encapsulating object data, you can maximize reusability, reduce data dependencies, and minimize program debugging time.
Encapsulation: encapsulation combines data and behavior in a package, and hides the data Implementation Method for the object user. The data in the object is called the instance field), and the process of operating the data is called the method ). Each specific class object instance has a set of specific instance domain values. The set of these values is the current state of the object. The key to encapsulation is that you cannot allow methods in the class to directly access the instance domains of other classes, but you can access your own instance domains. The program only interacts with the object data through the object method.
Encapsulate the features of the "black box" of the given object, which is the key to improving reusability and reliability.
Inheritance: A class can be created by extending another class. When an existing class is extended, the new class has all attributes and methods of the extended class.
Source: Huaqing vision embedded College)
This article from the "embedded learning world" blog, please be sure to keep this source http://farsight.blog.51cto.com/1821374/1300332