Object-oriented and process-oriented differences

Source: Internet
Author: User

Object-oriented and process-oriented


1. Process-oriented programming is essentially a computer-based approach to programming: input-----the output. The process-oriented programmer needs to change the habit of thinking to close to the internal working mechanism of the computer. In order to understand the system through the flow of information and its transformation, it not only increases the difficulty of program design, but also makes the comprehension of the procedure poor.
In object-oriented programming method, a popular optimization method is to use structured program design method.
Process-oriented programming method is generally suitable for top-down design.
Process-oriented programming approaches require a thorough, top-down design of the entire application architecture at the outset, and therefore require the program designer to have a thorough understanding of the problem domain.
Process-oriented programming methods are difficult to reuse software that has been previously designed.
2. Object-oriented programming is a bottom-up approach to program design, often starting from a part of the problem, 1.1 points to build the entire program. Object-oriented design is a data-centric, class as a tool to represent data, as the basic unit of dividing programs.
Object-oriented has several important features:
(1) Objective world has the object composition
(2) Object abstraction as Class
(3) There is an inheritance relationship between class and class
(4) Contact each other by passing messages between objects

About process-oriented and object-oriented programming 2010-06-10 10:00

Software developers may have used process-oriented and object-oriented coding at the same time, such as Java, C + +, C # are object-oriented languages, C is a process-oriented language, PHP supports both process-oriented and object-oriented functions, process-oriented and object-oriented features have their own advantages and disadvantages, Also have their own scope of application.

   Process oriented

Advantages: The performance is higher than object-oriented, because the class calls need to instantiate, the cost is relatively large, compared to consume resources, such as SCM, embedded development, Linux/unix and other general use of process-oriented development, performance is the most important factor.

Cons: No object-oriented easy to maintain, easy to reuse, easy to expand

   Object Oriented

Advantages: Easy to maintain, easy to reuse, easy to expand, due to the object-oriented packaging, inheritance, polymorphism characteristics, can design a low-coupling system, making the system more flexible and easier to maintain

Cons: Performance is less than process-oriented

   Some notable features of object-oriented programming include:

The focus of programming is on data rather than processes;

. The program is divided into so-called objects;

The data structure is designed to represent the characteristics of the object;

function as an operation on an object's data, with a data structure close together;

. Data is hidden and cannot be accessed by external functions;

. objects can be communicated through functions;

New data and functions can be easily added when needed;

In the process of programming, follow the design method from bottom to top (bottom-up).

Object-oriented programming is a new concept in the programming mode, which may mean different content for different people. Our definition of object-oriented programming is "object-oriented programming is a method that provides a common, independent memory space for data and functions that can be used as a template to create copies of similar modules when needed." This program design method is called object-oriented programming. "

As you can see from the above definition, an object is considered to be an independent interval in the computer's memory, where the data and a set of operations that can access the data are preserved. Because memory intervals are independent of each other, objects can be applied to many different programs without modification.

   what is object-oriented programming?

Object-oriented Programming (OOP) technology draws on the good ideas in structured programming and combines these ideas with new and powerful ideas to provide a completely new approach to your program design work. Typically, in an object-oriented program design style, you break a problem into a subset of interrelated subsets, each of which contains relevant data and functions. At the same time, you will sort these subsets into different levels in some way, and an object is a variable of a certain type that is already defined. When you define an object, you implicitly create a new data type.

   Object

In an object-oriented system, the object is the basic entity of the run time. It can be used to denote a person or a bank account, a data sheet, or anything else that needs to be handled by the program. It can also be used to represent user-defined data, such as a vector, a time, or a list. In object-oriented programming, the analysis of the problem is usually based on the natural relation between the object and the object. As mentioned earlier, an object occupies a certain amount of space in memory and has an address associated with it, just like the record in Pascal and the structure in C.

When a program is running, objects interact with each other by sending messages to each other. For example, the program contains a "Customer" object and an "account" object, and the customer object may send a message to the accounts object to query its bank statement. Each object contains data and code that operates on that data. Even if you don't know the details of each other's data and code, the objects can still interact with each other, all you need to know is the type of message that the object can accept, and the type of response the object returns, although different people implement them in different ways.

   class

We just mentioned that the object contains the data and the code that operates the data. All the data and code that an object contains can be made up of a user-defined data type through a class. In fact, the object is a variable of class type (ClassType). Once a class is defined, we can create multiple objects of this class, each related to a set of data, and the type of the data is defined in the class. Therefore, a class is an abstraction of an object of the same type. For example, mangoes, apples, and oranges are objects of the fruit class. A class is a user-defined data type, but in a programming language, it behaves the same as the built-in data type. For example, the syntax for creating a class object is identical to the syntax for creating an integer object.

   Data abstraction and encapsulation

The behavior of wrapping data and functions in a single unit (called a class) is called encapsulation. Data encapsulation is the most typical feature of a class. Data cannot be accessed by outsiders and can only be accessed by functions encapsulated within the same class. These functions provide an interface between the object data and the program. The concept of avoiding direct access to data by programs is called "Data hiding."

Abstraction refers to behavior that shows only the characteristics of the core and does not describe the details of the background. Classes use abstract concepts and are defined as a series of abstract attributes such as size, weight, and price, as well as functions that manipulate these properties. Class encapsulates all the core properties of the object that will be created. Because classes use the concept of data abstraction, they are referred to as abstract data types (ADT).

   Package

The encapsulation mechanism binds data and code together to avoid external disturbances and uncertainties. It also allows you to create objects. Simply put, an object is a logical entity that encapsulates the data and the code that operates the data.

Within an object, some code and/or some data can be private and inaccessible to the outside world. In this way, objects provide different levels of protection to internal data to prevent unintended changes to unrelated parts of the program or to use the private parts of the object incorrectly.

   Inheritance

Inheritance is a method that allows an object of one type to obtain the properties of another type of object. It supports the concept of classification by class. For example, robins belong to flying birds and also to birds. The principle of this classification is that each subclass has a common attribute of the parent class.

In OOP, the concept of inheritance well supports the reusability of code (reusability), which means that we can add new features to an already existing class without having to change the class. This can be achieved by deriving a new class from the existing class. This new class will have the attributes of the original class, as well as the new features. The charm and power of the inheritance mechanism is that it allows programmers to take advantage of already existing classes (close to need, rather than fully conforming to the required classes), and can modify the class in some way without affecting other things.

Note that each subclass defines only those attributes that are unique to the class. If you do not classify by class, each class must explicitly define all of its attributes.

   polymorphic

Polymorphism is another important concept of OOP. Polymorphism means that things have different forms of ability. For example, for a different instance, an operation might behave differently. This behavior relies on the type of data that you want to manipulate. For example The addition operation, if the data of the operation is a number, it sums two numbers. If the data for the operation is a string, it will concatenate two strings.

Polymorphic mechanisms enable objects with different internal structures to share the same external interface. This means that although specific actions are different for different objects, they can be called in the same way through a common class. Polymorphism is widely used in the process of implementing inheritance.

The object-oriented programming language supports polymorphism, and the term is called "one Interface Multiplemethod (an interface, multiple implementations)". In simple terms, the polymorphic mechanism allows a set of related but not identical actions to be raised through the same interface, which reduces the complexity of the code. What action should be made in a particular situation, which is determined by the compiler, without the need for manual intervention by the programmer.

In a multi-function program, many important data are declared as global variables so that they can be accessed by all functions. Each function can have its own local variable. A global variable is easily changed by a function inadvertently. In a large program it is difficult to tell which variables are used by each function. If we need to modify the structure of an external data, we have to modify all the functions that access that data. This can easily lead to the creation of bugs.

Another serious flaw in structured programming is the inability to simulate real-world problems well. This is because the function is process-oriented, not really the individual elements that correspond to the problem.

   Some features of process-oriented program design are as follows

. emphasis on doing (algorithm);

Large programs are separated into many small programs, which are called functions;

Most functions share global data;

. Data is opened by one function to another function. function to convert data from one form to another.

Application design method from top to bottom.

   Dynamic Binding

Binding refers to the behavior of linking a procedure call to the corresponding code. Dynamic binding means that the code associated with a given procedure call is only known at run time. It is very closely related to polymorphism and inheritance. A function Call of a polymorphic reference is determined by the dynamic type of the reference.

   Message Delivery

An object-oriented program consists of many objects that need to communicate with each other. Therefore, in the object-oriented programming language, the main steps of programming are as follows:

1. Create classes that define the object and its behavior;

2. Create objects by class definition;

3, establish communication between the objects.

Objects communicate with each other by sending and receiving information, which is similar to the transmission of information between people. The concept of information transfer makes direct simulation of the real world easier and establishes system communication.

For a particular object, the message is the request to execute a procedure, so the receiving object of the message invokes a function (procedure) to produce the expected result. The content of the message that is passed includes the name of the object that receives the message, the name of the function that needs to be called, and the necessary information.

An object has a life cycle. They can be created and destroyed. As long as the object is in its lifetime, it can communicate with it.

   the advantages of OOP

OOP has many advantages, both for the programmer and for the user. Object-oriented provides a solution to many of the problems in software product expansion and quality assurance. This technology can greatly increase the productivity of programmers, and improve the quality of software and reduce their maintenance costs. Its main advantages are displayed in the following:

1, through inheritance, we can greatly reduce the redundant code, and expand the use of existing code;

2. We can build our program on standard modules (the so-called "standard" refers to an agreement between programmers), without having to start all over again. This can reduce software development time and increase productivity;

3, the concept of data hiding to help programmers to protect the program from external code attack;

4. Allows multiple instances of an object to exist simultaneously, and does not interfere with each other;

5. Allow the object in the problem space to be mapped directly into the program;

6, the object-based project can be easily divided into separate parts;

7. The data-centric design approach allows us to capture more details of the achievable model;

8, the object-oriented system is easy to upgrade from small to large gradually;

9, the communication between objects used by the message-passing technology and External System interface part of the description is simpler;

10, more convenient to control the complexity of software.

When it is necessary to combine all of the above mentioned features organically in an object-oriented system, the relative importance between them depends on the type of engineering and the preferences of the programmer. Many things have to be considered in order to gain some of these advantages. For example, the object library must be reusable. Technology is still developing, and the existing products will be upgraded quickly. If reuse is not achievable, then strict control and management is required.

Easy-to-use development software is often difficult to write. Object-oriented programming tools are expected to solve this problem.

   Object-oriented programming language

Object-oriented technology is not a privilege for a particular language. Like structured programming, OOP concepts can be implemented in many languages such as C and Pascal. However, when the program is getting bigger and larger, the programming process becomes clumsy and confusing. And a programming language that supports OOP concepts can make everything easier.

A language must support several major OOP concepts in order to call it object-oriented. Depending on the OOP features supported, the language can be divided into the following two categories:

1. Object-based programming language;

2, object-oriented programming language.

Object-based programming languages only support encapsulation and object identification.

An object-oriented programming language has the following important features to support:

. Data encapsulation

. Data hiding and access mechanisms

Automatic initialization and cleanup of objects

. Operator overloading

The language that supports object style programming is called object-based programming language. They do not support inheritance and dynamic binding.

Ada is a typical object-based programming language.

Object-oriented programming not only contains the characteristics of object-based programming, but also supports inheritance and dynamic binding.

Application of OOP

   the most promising application areas for OOP are as follows

1, real-time system;

2, simulation and modeling;

3. The object database of physiognomy;

4, hypertext, hypermedia and Extended text;

5, AI and expert system;

6, neural network and parallel programming;

7, decision support and office automation system;

8, Cim/cam/cad System.

Object-oriented and process-oriented differences

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.