"Overview of Object-oriented programming" cow plum blossom

Source: Internet
Author: User

an overview of object-oriented programming

New Yongmei

(Nanyang Polytechnic Institute of Technology, Nanyang 473000, Henan)

Abstract: The differences between traditional programming methods and object-oriented programming methods are analyzed, the characteristics of object-oriented programming are analyzed emphatically, and the steps and advantages of object-oriented programming method are introduced.

Key words: Object-oriented programming; Object Package Inherited

Abstract:to analyse the difference of procedure-oriented programming and object-oriented programming. Emphasize introduce the characteristics, steps and advantages of OOP. Key words:object-oriented programming; Object; encapsulation; Inheritance

Object-oriented technology has caused a revolution in programming methodology, which has replaced the process-oriented programming technology and become the mainstream technology in the field of computer application development nowadays.

A comparison of process-oriented programming and object-oriented programming

The traditional program design technique is a design method oriented to the data process, which focuses on the description of the algorithm and answers the question of "What to do and how to do". This method uses the data and process as independent entities, the data represents the object in the problem space, which is used to express the information in the actual problem, and the program code is used to process the data.

Object-oriented design approach is fundamentally different from the traditional approach to data-oriented processes. Object-oriented program design method focus on demand analysis and design repeatedly, the answer is "What to do, why do" problem, it allows programmers to get rid of the specific data format and process constraints, can focus on research and design to deal with the object. The new object class can be generated by inheriting the nature of an existing object class, so the reusability of such implementations is natural and accurate. The use of object-oriented approach to express knowledge, not only strong expression, can represent a fairly wide range of knowledge, able to describe a very complex objective things, but also has a strong modularity, high degree of structure, easy to achieve stratification, is conducive to design, reuse, expansion, modification and a series of advantages. Therefore, the application foreground of object-oriented program design method in the field of artificial intelligence, such as knowledge processing and expert system, is bright and optimistic.

Ii. Basic concepts in object-oriented programming language1. Objects

An object is the basic component of the runtime in an object-based system, which is the encapsulation of properties and behaviors, including facilities for communicating with other objects. Objects have three different meanings: real objects, problem objects, and computer objects. The real object is the entity that exists in the actual world, and the problem object is the abstraction of the reality object in the problem domain, which is used to accomplish some behavior as needed; The computer object is the representation of the problem object in the computer system, which is the encapsulated communication unit of data and operation. Therefore, an object in an object language refers to a computer object.

2. Class

A class is a description of a set of objects that have the same data and operations, that is, a class is an abstract generalization of a set of objects. Its functions are as follows: first, as the description mechanism of objects, the common properties and behaviors of the group objects are engraved, and secondly, as the basic unit of the program, it is the facility to support the modular design, and the classification relation on the class is the standard of module partition. A class has three components: data, operations, and interfaces. The data carves the state of the object, manipulating the behavior of the object, all the data in the class is private, and the interface makes the operation visible to the outside.

3. Message

A message is a message that can be passed between an object and an object. It requires an object to perform a specification of an operation defined in a class, consisting of three parts: an object that accepts a message, a message selector (also known as a message name), 0 or more arguments (argument).

the characteristics of object-oriented programming language1. Abstraction

Abstraction is the neglect of the minutiae of the problem in order to pay more attention to the aspects related to the current goal. Abstraction is not a comprehensive description of a problem, but rather a core, generic, key issue that illustrates its nature, rather than commonality and detail that can be left to lower-level derived classes to solve. For example, we want to design a student performance management system, to examine the student this object, we only care about his class, school number, grades, etc., and do not care about his height, weight of this information. Abstract includes two aspects, one is the process abstraction, the other is the data abstraction. Process abstraction refers to the fact that any operation that explicitly defines a function can be viewed by the user as a single entity, although the operation may actually be done by a series of lower-level operations. Data abstractions define the data types and actions that are applied to objects of that type, and limit the values of the objects to be modified and observed only by using these operations.

2. Encapsulation

Encapsulation is one of the object-oriented features and is the main feature of object and class concepts. Encapsulation is the process and data is surrounded, access to data only through the defined interface. Object-oriented computing begins with this basic concept that the real world can be portrayed as a series of fully autonomous, encapsulated objects that access other objects through a protected interface. Once the attributes of an object are defined, it is necessary to determine the visibility of those attributes, which are visible to the outside world and which are used to represent the internal state. The interface of the object is defined at this stage. In general, direct access to an object's actual representation should be prohibited, and objects should be accessed through the manipulation interface, known as information hiding. In fact, information hiding is the user's knowledge of encapsulation, and encapsulation provides support for information hiding. Encapsulation ensures that the module has a good independence, making the program maintenance and modification easier. Modifications to the application are limited to the inside of the class, so you can minimize the impact of application modification. Encapsulation, abstraction, and information hiding are important techniques to reduce software complexity.

3. Inheritance

Inheritance is a hierarchical model of a junction class and allows and encourages the reuse of classes, which provides a way to articulate commonalities. A new class of objects can be derived from existing classes, a process known as class inheritance. The new class inherits the attributes of the original class, which is called the derived class (subclass) of the original class, and the original class is called the base class of the new class (The parent Class). Derived classes can inherit methods and instance variables from their base classes, and classes can modify or add new methods to make them more suitable for special needs. This also reflects the nature of the general and special relationship. Inheritance is a good solution to the problem of reusability of software. For example, student classes, all students can be seen as derived from the same student class, but each student's specific performance behavior is different, this is due to the derivation of different subclasses, each subclass added different attributes. Inheritance has a number of benefits for software development:

(1) Software reusability: If an operation is inherited from another class, all the source code for this operation does not have to be rewritten.

(2) Code reuse: There are multiple levels of code reuse in object-oriented programming, and at one level, many unrelated programmers and the same classes that projects can use.

(3) Interface consistency: When many classes inherit from the same class, in all cases the classes inherit the same operations, which makes it easy to ensure similar interfaces for the same class.

(4) Rapid prototyping technology: if most of a software system can be composed of reusable components (such as class libraries, etc.), then most of the energy in development can be spent on understanding the new and special parts of the system. The development of software systems is fast and easy, and this development is called rapid prototyping technology.

4. polymorphism

Polymorphism in programming languages refers to the same language structure that can represent different types of entities or operate on different types of entities. In object-oriented programming languages, there is a unique polymorphism in the inheritance relationship between classes and objects; If class p is the parent of class S, then an object s of subclass s can be used anywhere the object P of class p uses, which means that a public message set (that is, an operation) can be sent to objects of class p and class S , which is a manifestation of polymorphism. Polymorphism is related to the operation of the language side, and the run-time link indicates that the system links a selector to the specific method of implementing it during runtime, which is much more square-denatured and more flexible than the compile-time linkage in implementing polymorphism.

The advantage of polymorphism is that the high-level code (algorithm) writes only once, and satisfies the reuse requirements by providing different low-layer services. In object-oriented programming, the combination of various polymorphism methods and other methods can greatly improve the reuse and sharing of code. Object-oriented programming method overcomes most of the shortcomings of traditional programming methods, there are many object-oriented programming languages, such as VC + +, object Pascal Visual Basic and so on.

four, object-oriented programming steps and Advantages

The main purpose of object-oriented software development is to decompose the base class with reusable software and to speed up the problem solving with sub-class, shorten the development time and reduce the cost of software development. By changing the implementation of one or more classes, it affects localization, thus reducing the cost of software maintenance. The steps are outlined as follows:

1. Select the main data object;

2. Define the messages that each object can receive and send;

3. Describe the data elements that are necessary to implement each object;

4. Describe the method of each object with a small instruction manual;

5. Final optimization of the entire design.

Its advantages lie in:

1. Easy Maintenance

2. Extensibility

3. Code Reuse

v. Conclusion

From the above overview, we can see that object-oriented programming has become an important component of modern programming technology reasons. From process-oriented to object-oriented is a leap in program design. The reason why people use object-oriented programming techniques is to:

1. Improve the operational efficiency of the program

2. Improve the efficiency of the programming process

3. Improve the maintainability of the program

The use of object-oriented technology is not necessary, but for a large complex application system development, if the use of object-oriented technology, the development efficiency will be greatly improved.

Reference Documents :

[1] Xu Jiafu, etc. object-oriented programming language [M]. Nanjing: Nanjing University Press. 1992.

[2] Jadong, Yang Xiaofeng. Discussion on some problems in object-oriented technology [J]. Small microcomputer Systems-1998.

[3] full-handle ZHE. Design of object-oriented software specification language [J]. Software Journal. 1995.

[4] [beauty] setphen Prata. C + + primeplus Chinese version (4th edition) [M]. Jianchun translation. Beijing: People's post and Telecommunications Press, 2002.

Overview of object-oriented programming, cow plum blossom

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.