C - basic information (1) object oriented
White ice 2021-05-04 15:19:54

First of all, let's review what is the object .

The object here is not us c# Examples in , stay c# We can also regard a class as an object . But in object-oriented programming, this object should be an implementation object , The definition of an object is what this implementation does . From simple to complex can be seen as an object , It can not only express concrete things , Can also represent abstract rules 、 Plan or event .

It is said that everything is the object , Do you have to face all kinds of programming when programming , Isn't that complicated .

So object oriented , This object , Refers to the object . The so-called object refers to the objective entity and the subjective abstract concept .

Why object oriented programming ?

Object oriented is to solve the maintainability of the system , Extensibility , Reusability , Let's think more , Why can object-oriented solve the maintainability of the system , Extensibility , Reusability ?

We can find out from the history of object-oriented :

Computers are created to help people solve problems , But machines are machines after all , It needs people to set the next step instructions to complete the next step operation , Finally get the result we want . So no matter how complicated the program is , Computers can handle it easily . So in the past, the code is more and more incomprehensible, and the maintenance is more and more complex . So it's called structured programming .

The basic idea of structured programming is :

  1. Control the process in an orderly way , That is to say, the execution order of the program is limited to order 、 Branches and loops ;
  2. Turn common processing down to routines ( function ).

The advantage of structured programming is :

Three restrictions : It greatly reduces the degree of freedom of the program , Reduced combinations , So that the program is not too complicated . For this point , The order of structured programming 、 Branches and loops can implement all algorithms , Although it reduces the complexity and flexibility of the program , But the implementation ability of the program is not reduced .

routine ( function ): We just need to know the process ( function ) Name , You don't need to know the internal details of the process , namely “ Black box ”.

Although structure solves the complex problem of program control flow , But the program includes not only the control structure , It also includes the data to be processed . As processing data increases , The complexity of the program will also rise . Now , Object oriented programming is coming !

Object oriented programming is divided into several steps ?

Object oriented is an idea , He asked us to analyze and solve problems , Turn thinking and emphasis to the object in reality , And then through UML Tools to clarify the relationship between these objects , Finally, the object and the relation between the objects are realized by the object-oriented language . It is divided into object-oriented analysis (OOA), Object oriented design (OOD), Object oriented programming (OOP) Three big steps .

1、 First, analyze the needs , Don't think about how to program it first , First, what are the stable objects in the demand , What is the relationship between these objects .

2、 Analyze the requirements from the first step , By further extending the model , Become achievable 、 Cost compliant 、 Modular 、 A model of low coupling and high cohesion .

3、 Using an object-oriented implementation model

How to change process oriented thinking to object oriented thinking ?

When we get this requirement, we should not directly think about how to realize it . We should analyze the needs , Find the corresponding object in the demand , According to these objects found to analyze the relationship in these objects . So after we get the requirements, we first analyze the modeling to understand the relationship , Developed Maintainable , Scalable , reusable , High quality modules . The change of thinking , It may take a process

Three characteristics of object-oriented :

【 encapsulation 、 Inherit 、 polymorphic 】

The advantages of object-oriented programming ?

A、 Reusability : It's good for the speed of development If you want to develop a function, it's very difficult to implement it , At this time, there is another technology that can solve the problem very well , Its advantages are brought into play

B、 encapsulation / Abstraction : The structure is clear It's standard Normalization Easy to understand More readable

C、 Inherit : Easy to expand , It's easy to develop your own functions without changing the framework

本文为[White ice]所创,转载请带上原文链接,感谢