Home > Common Problem > What does OOP thinking refer to?

What does OOP thinking refer to?

Guanhui
Release: 2020-06-28 10:15:40
Original
11704 people have browsed it

OOP thinking refers to object-oriented programming. Object-oriented emphasizes the "abstraction", "encapsulation", "inheritance" and "polymorphism" of objects. Compared with process-oriented, this idea focuses on some methods of using objects. To solve problems, different functions may be solved by different objects.

What does OOP thinking refer to?

Classes and Objects

Class: A class is an abstract concept, a class of things with the same characteristics General term, such as college students;

Object: The object is the entity of a specific thing, such as a specific student Zhang San.

Three major characteristics of object-oriented

1. Encapsulation

Encapsulation means that a class can have some private properties and methods, which can solve a problem The solution is encapsulated and only a part of the interface is provided to the outside world. The problem can be solved by calling the interface, but the outside world does not know what the specific solution is.

2. Inheritance

A class can obtain the non-private properties and methods of another class through inheritance, so that the properties and methods of the inherited class can be reused.

3. Polymorphism

Child objects instantiated by the same parent class can get different results by calling the same method. This is polymorphism.

Seven Design Principles

SOLID Principle

Single Responsibility Principle: Only one class/interface/method can have one and only one responsibility;

Open-Closed Principle: Open to expansion, closed to modification;

Richter Substitution Principle: All places that reference a base class must be able to transparently use objects of its derived classes;

Interface isolation principle: users cannot be forced to rely on interfaces they do not use. Using multiple interfaces is better than using one total interface;

Dependency inversion principle:

A. High-level modules do not Should depend on low-level modules, both should depend on abstraction

B. Abstraction should not depend on details, details should depend on abstraction. C. Program for interfaces, not for implementation

Di Mitte's Law: A software entity should interact with other entities as little as possible

Principle of combination reuse: Try to use combination/aggregation, do not use class inheritance

Recommended tutorial :《PHP

The above is the detailed content of What does OOP thinking refer to?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
oop
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template