Basic object-oriented concepts (1)

Source: Internet
Author: User

1. Object Technology

Contains abstract, encapsulation, and polymorphism (polymorphism action, encapsulation, polymorphism) to build software structures, and is supported by other tools such as languages and databases.

2. milestones in the development of Object-Oriented Technology

Simula C ++ the UML

1967 late 1980 s 1996

1972 1991 2004

Smalltalk Java UML2

3. Important Concepts of OOP

(1) object.
Objects are all things that people need to study. From the simplest integer to the complex aircraft, they can be regarded as objects. They can not only represent specific things, it can also represent abstract rules, plans, or events.

(2) object status and behavior.
An object has a state, and a data value is used to describe its State.
The object also has operations to change the object state. The object and its operations are the behavior of the object.
Objects combine data and operations to encapsulate data and operations in the unity of objects.

(3) class.
Abstract objects of the same or similar nature are classes. Therefore, the object is abstracted as a class, and the class is embodied as an object. It can also be said that the instance of the class is an object.
A class has attributes. It is an abstraction of the object state and describes the attributes of a class using a data structure.
The class has operations. It is the abstraction of the object's behavior. It is described by the Operation name and the method to implement this operation.

(4) class structure.
There are several classes in the objective world, which have some structural relationships. There are usually two main structural relationships: general-specific structural relationships, and overall-partial structural relationships.

① General: the specific structure is called the classification structure. It can also be called the "or" relation, or the "is a" link.
② Whole-some structures are called assembly structures, and the relationship between them is a kind of "and" relationship, or "has a" relationship.

(5) messages and methods.
The structure for communication between objects is called message. In an object operation, when a message is sent to an object, the message contains the information of the recipient performing an operation. To send a message, you must at least specify the name of the object that receives the message and the name of the message sent to the object (that is, the object name and method name ). It is also necessary to describe the parameters. The parameters can be the names of variables known to the objects that know the message, or the names of global variables that all objects know.

The implementation process of operations in a class is called a method. A method includes a method name, a parameter, and a method body.

4. Three Important features of Objects

(1) behavior-What operations and methods can be applied to objects?

(2) State-how should an object respond after those methods are applied?

(3) identification-how to distinguish different objects with the same status and behavior?

5. attributes and methods of Objects

(1) A class attribute is used to record a certain nature of the class and has nothing to do with a specific instance. No matter how many instances are declared, this attribute is only one.

(2) describes what an object can do, can solve a problem, and typical operations within a certain range

6. Four important object-oriented principles

(1) abstraction.
Abstract refers to emphasizing the essence and inherent attributes of an object. In system development, abstraction refers to the meaning and behavior of objects before deciding how to implement objects. Using abstraction can avoid premature consideration of some details.

Class implements the abstraction of object data (that is, State) and behavior.

(2) Encapsulation (Information Hiding ).
Encapsulation is the basis for ensuring excellent controllability of software components.
Object-oriented classes are well-encapsulated modules. class definitions explicitly separate their descriptions (User-visible external interfaces) from implementations (User-invisible internal implementations, its internal implementation provides protection according to its specific scope.
Objects are the most basic unit of encapsulation. Encapsulation prevents changes caused by program dependency. Object-oriented encapsulation is clearer and more powerful than traditional language encapsulation.

(3) inheritance.
Inheritance is the mechanism by which child classes automatically share parent class data structures and methods. This is a relationship between classes. When defining and implementing a class, you can base on an existing class and take the content defined by this existing class as your own content, and add some new content.

Inheritance is the most important feature of object-oriented programming languages different from other languages and is not available in other languages.

In the class hierarchy, a subclass inherits only the data structure and method of a parent class, which is called Single-re-inheritance.
In the class hierarchy, child classes inherit the data structures and methods of multiple parent classes, which are called multi-inheritance.
In software development, the inheritance of classes makes the software open and scalable. This is an effective method for information organization and classification. It simplifies the workload of object and class creation, added code reusability.
Inheritance is used to provide a standard class level structure. Through the inheritance relationship of classes, public features can be shared, improving the reusability of software.

(4) Modularization.

Divides a complex system into several parts to make it easier to understand and use.

7. Common object-oriented layer-3 Structure

Gui

Domain

Database

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.