C ++ - Object-Oriented Programming Object-oriented -000-

C + ± -000- object-oriented programming object-oriented -2020-3-16

I. Overview of Object-Oriented

Object-oriented (Object Oriented, OO) it is a design concept, now this idea has been applied not only in software design, database design, computer-aided design (CAD), network design, artificial intelligence algorithm design and other fields are beginning to use this idea.

For different areas of object-oriented applications, object-oriented analysis can be divided into object-oriented (Object Oriented Analysis, OOA), object-oriented design (Object Oriented Design, OOD), OOP (Object Oriented Programming, OOP), object-oriented test (Object oriented test, OOT) and object-oriented maintenance (Object oriented Soft maintenance, OOSM).

There are three major features of object-oriented, i.e. encapsulation , inheritance and polymorphism .

(1) Package

Package has two functions, one is to package different small objects into a large object , the other part of the inner shielding properties and functions to the outside world . For example, a car is a large object, which consists of the engine, chassis, body and wheels, etc. These small objects. In the design of these small objects can first design and then determine the properties of an object between small size and other aspects of their contact with each other through, and finally you can install into a car.

(2) inheritance

Inheritance is closely related to the concept and classes. Inheritance is a subclass of the automatic sharing of data structures and methods of the parent class, which is a relationship between classes. In the definition and implementation of a class, they can be based on an existing class above, the contents of the existing classes as defined by their content, and add some new content.
In the class hierarchy, the subclass inherits only a data structure and methods of the parent class, referred to as a single inheritance, the subclass inherits the data structure and method for multiple parent class, referred to as multiple inheritance.
In software development, class inheritance established by the software is open, scalable, which is an effective information organization and classification method, which simplifies the object, creating class workload, increased code reusability.
Inheritance is the most important feature of object-oriented programming language is different from other languages, other languages do not. The use of inheritance, the ability to share common characteristics, improving the reusability of the software.

(3) Polymorphism

Polymorphism is the same behavior may be applied to the multiple types of objects, and different results are obtained. Different objects, receive the same message may produce different results, a phenomenon called polymorphism. Polymorphism allows each object to fit their own way to take in response to a common message.

Second, the object-oriented and process-oriented programming

1. Process-oriented programming

The main idea of the programming process is what to do after what to do first, to achieve a specific function in the process. A large implementation may also be divided into various modules, each module may be divided by function, and then combined together achieve a particular functionality. During programming, the program module may be a function, or may be the entire source file.
The main process program in the data center, a conventional process for the decomposition of the function belonging to the structure analysis method. Analysis of real-world objects will be seen as a system of large processing system, which is then broken down into several sub-processes, to solve the problem of the overall control system. During the analysis, the data link between the sub-described processes, finishing the execution order of the respective sub-process.
Process-oriented programming in general process is as follows:
in the real world -> oriented process modeling (flow chart, variables, functions) -> procedure-oriented language -> execution to solve.
The stability of the programming process, can be modified and reusability weak.

(1) Software poor reusability

Reusability means the same thing without modification or can be modified several times using slightly modified nature. Software reuse is one of the goals of software engineering to pursue. Different processes by a different structure, when the process is changed, the structure needs to be changed, the pre-development code can not be fully recycled.

(2) software maintainability

Software engineering emphasize software maintainability, stressed the importance of documentation, the provisions of the final software product should consist of complete, consistent configuration ingredients. In the software development process, it has always stressed the readability of the software can be modified and testability is an important indicator of quality software. Process-oriented programming because the search software reusability, resulting in the cost and maintenance cost is also high, and a large number of modified code, there are many unknown vulnerabilities.

(3) the development of the software can not meet user needs

Large-scale software systems generally relates to various fields of knowledge, process-oriented programming is often the lowest level description of each of the software, different for different areas of design structure and handling mechanism, when sending the user needs change, it is necessary to modify the structure of the lowest level. When dealing with large changes in user demand, the programming process will not be modified, can lead to re-develop the software.

2. Object-Oriented Programming

Convoluted process-oriented programming with a data structure, the relationship between the complex combinatorial logic, and the detailed process data, advanced algorithms, the process of developing programs for the algorithm can be described as the additional data structures. Process-oriented development is the boundary between the data analysis process and where, then solve the problem. Is thinking from another point of view, the programming will be designed to meet the people's thinking logically object-oriented thinking.
Object-oriented programmer's tasks include two aspects: First, the various types of objects and the required design, i.e., the data and decides which operations package together; Second consider how to send a message to the relevant subject, to effect the desired task. At this time it is always like a scheduler, constantly sending a message to each object, so that these objects come alive (or activate these objects), to complete the work within their responsibilities.
Operation of the various objects to complete the overall task is complete. Obviously, a large task, the object-oriented programming method is very effective, it can greatly reduce the difficulty of the work program designers to reduce the opportunities for error.
Object-oriented development program may be described as "subject + message." Object-oriented programming in general process is as follows:
in the real world -> object-oriented modeling (class diagrams, object, method) -> object-oriented language -> execution to solve.

3. The object-oriented features

Object-oriented technology fully reflects the decomposition, abstraction, modularity, information hiding and other ideas, which can effectively improve software productivity and shorten software development time and improve software quality, it is an effective way to control complexity.
Object-oriented not only for ordinary people, but also for managers. Reduce maintenance costs of technology can free up resources managers to invest their application to be processed. In the managers seems, is not a pure object-oriented technology, which will give the organization the enterprise that is also the manager's job can bring change.
When a company adopts object-oriented, the organization will change. Reuse library and library management needs class, every programmer should be added to one of two groups: one is the design and preparation of a new class group, and the other is the application class to create a new application group. Less emphasis on object-oriented programming, requirements analysis will become relatively more important.
There are object-oriented programming is easy to modify the code, the code reusability, three features to meet user needs.

(1) easy to modify the code

Object-oriented programming code is encapsulated in the class to which, if an attribute class changes, to modify only need to implement the member function of the class, other program functions do not change. If the class attribute changes in the larger, then use the inherited method to re-derive a new class.

(2) Code high reusability

Classes are object-oriented programming package having a specific function, requires the use of a particular class of functions, just declare class and its member functions to call. If desired functions in different classes, can be multiple inheritance, encapsulation members of different classes in a class. Implementing functions can be freely combined like building blocks, greatly improving the reusability of code.

(3) to meet customer needs

Because of the code reusability of object-oriented programming, the user's requirements change, only need to modify the class changes. If the user's requirements change is large, then reassemble the class, the class will be a big change redeveloped Functional no changes can be directly used to use. Object-oriented programming can respond to changing demands in a timely manner.

Published 91 original articles · won praise 101 · Views 3270

Guess you like

Origin blog.csdn.net/weixin_41096569/article/details/104898750