The essence of program design is to take the problem that people encounter in real life through abstract processing, and use programming language to change to the level that computer can understand. From the beginning to the present, the program design has undergone 3 stages of process programming, structured programming and object-oriented designing.
Procedural programming requires the developer to carefully design and tightly control every step of the program.
Structured programming requires developers to complete the program before coding, design a variety of icons, draw a variety of data flow, indicating the interaction between functions, is a top-down, gradually refinement, the program Structure modular program design method.
Object-oriented Programming (OOP) is the basic unit of the program and encapsulates the program and data to improve the reusability, flexibility and extensibility of the software, each of which represents a specific thing (or "entity") in the real world.
Object-oriented programming is now the mainstream program design ideas, the current popular Java, C # and so on are object-oriented programming language. The object-oriented programming idea is to make the program fully consistent with the real-world entities, so that developers and users can better understand and communicate.
The basic features of object-oriented programming are encapsulation, inheritance and polymorphism.
1. Encapsulation
Encapsulation refers to the binding of the State and behavior of an object to a logical unit that encapsulates an objective thing into an abstract class. Encapsulation allows you to hide the implementation details of a class, and the user can access the object of that class through a specified method without having to care about its internal details.
2. Inheritance
Inheritance is when a class inherits another class, that is, the properties and methods of another class can be obtained, the inheritors are subclasses, and the inheritors are the parent classes. By inheriting between classes, the code is reused, new properties and methods can be added to the subclass, and methods in the parent class can be re-implemented in a specific way. In Java, a subclass can inherit only one parent class, and cannot inherit multiple parent classes at the same time, which is the top-level parent class for all classes.
3. polymorphic
Polymorphism in Java means that an object variable is polymorphic, and a variable of type A can point to an object of type A and to any subclass of a. The flexibility of parameter types can be enhanced by passing parameters in a polymorphic form in a method call. A variable of an interface type can also point to an object of the interface implementation class.
Summarize:
Object-oriented programming is the current mainstream program design idea, the Java language belongs to the object-oriented programming language, so understanding object-oriented programming thought is very important to learn Java development.
Encapsulation, inheritance, and polymorphism are the 3 basic features of object-oriented programming, which provide a good implementation in the Java language and are often involved in the Java development process. An in-depth understanding of encapsulation, inheritance, and polymorphism concepts helps beginners learn and apply the Java language. This article only provides a primer, I hope you crossing continue to expand the multi-Java, object-oriented programming and its characteristics of understanding and understanding.
"Reproduced use, please specify the source:http://blog.csdn.net/mahoking"
"Reproduced use, please specify the source:http://blog.csdn.net/mahoking"
Object-oriented programming and its basic features