Methodology of object-oriented programming

Source: Internet
Author: User
Tags abstract definition

Methodology of object-oriented programming

Object-oriented program design absorbs all the advantages of structured programming, and considers the mapping relationship between real world and object oriented solution space, and its goal is to simplify the solution of real world problems as much as possible.

object-oriented programming puts the data and the operation of the data together as an interdependent and indivisible whole, which employs data abstraction and information hiding technology. It abstracts objects and operations on objects into a new type of data - class , taking into account the relationships between different objects and the reusability of object classes.

I will share with you some of the basic object-oriented concepts that I understand. We hope to help you.

First, the basic concept of the object

Object-oriented = Object + class + inherit + message communication

The most prominent feature of object-oriented system is encapsulation, inheritance and polymorphism, measuring a programming language to see if it is an object-oriented programming language, mainly see whether it has the above three characteristics. such as C++,c#,java and so are the programming language.

second, class and object

A class is an abstract definition of an object or set of objects that have the same properties and services.

Classes and objects are abstract relationships with concrete instances, and a specific object is called an instance of the class.

Whether a rich class library is established is an important symbol to measure the maturity of an object-oriented programming language.

Object is an entity used to describe objective things in a system, which is a basic unit of a system and an instance of a class.

Object-Oriented software system is composed of objects, complex objects are composed of relatively simple objects. In other words, object-oriented methodology uses object decomposition to replace the functional decomposition of traditional methods.

The properties and methods of the object are called "members" of the object. It is the main part of the constituent object.

Class can be said to be the blueprint of the object (blueprint)

Iii. three elements of the object

Object three elements: Object flags, properties, and services

Object flags: The name of the object that uniquely identifies the object within the system.

Properties: Also called state or data, used to describe the static characteristics of an object. In some object-oriented programming languages, properties are often referred to as member variables or short variables.

Service: Also known as an operation, behavior, or method, used to describe the dynamic characteristics of an object. In some object-oriented programming languages, services are often referred to as member functions or short functions.

Encapsulation: An important principle of an object to separate the definition and implementation of an object. It has two meanings: first, the object is an indivisible whole that is formed by the close integration of all its properties and all services; second, the object is an opaque black box, and the data that represents the state of the object and the code that implements the operation are encapsulated in a black box. When you use an object, you only need to know the form of the interface it provides to the outside world, without having to know its data structure details and the algorithm that implements the operation. Invisible from the outside, it is more impossible to directly modify the object's private properties from the outside.

lchangemark, this is a feature that is not exposed to the outside, and is intended for use only by the object itself.

l (Protected) getmark, which is only declared to the outside world, only provides services to its derived class objects.

getname and getmajor, which are public segments, are public functions that can respond to requests from outside objects.

                                                                                                                                                                                               

    four, Inheritance (inheritance) and polymorphism (polymorphism)  

Inheritance: The main feature of object-oriented programming language differs from other languages, which is the mechanism of sharing attributes and operations among classes. It is defined as: an object of a special class (or subclass, derived class) has all the properties and services of its general class (or parent class, base class), and is called a special class of inheritance ( divided into single inheritance and multiple inheritance ) of the generic class. In object-oriented methodology, inheritance is one of the important reasons to improve the efficiency of software development.

Polymorphism: When an object receives a message, it is given the same message, and the object may produce a completely different result.

In general, it is divided into: polymorphism at compile time and runtime polymorphism.

Parameter polymorphism (implemented using function overloading) is the most widely used polymorphic and is the purest polymorphic.

Polymorphism not only increases the flexibility of object-oriented software system, but also reduces information redundancy, and significantly improves the reusability and extensibility of software.

When you define a function overload, the function has the same name, but the number or type of arguments with the function must be different, or there will be two semantics.

The class that is used to refer to the inheritance is the "parent class", and the inherited class is called "subclass".

In object-oriented systems, operators can be overloaded in addition to functions that can be overloaded. So is java.

Note: A compile-time polymorphism is typically implemented by a function overload, while the runtime's polymorphism is used by a virtual function.

Methodology of object-oriented programming

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.