Basic knowledge of Python object-oriented (1)

Object-oriented (OOP) basic concepts

Object Oriented Programming-Object Oriented Programming (OOP)

aims

Understand the basic concepts of object-oriented

Basic Object Oriented Concepts

  • We learn that before programmatically oriented process of
  • Object-oriented and process-oriented, two different programmatically
  • Contrast process-oriented features, can better understand what is object-oriented

1.1 Process and function (Science)

  • Process is an early programming concept
  • Process is similar to function, can only be executed, but no return value
  • Functions can not only be executed, but also return results

1.2 Basic concepts of process-oriented and object-oriented

1) Process-oriented-how to do it?

1. Gradually implement all the steps to complete a certain requirement from beginning to end.
2. According to development requirements, encapsulate some functional independent codes into one function after another.
3. The final completed code is to call different functions sequentially

Features

1. Pay attention to steps and processes, and don't pay attention to the division of responsibilities.
2. If the requirements are complex, the code will become very complicated.
3. The development of complex projects without a fixed routine makes development very difficult!

2) Object-oriented-who will do it?

1. Compared with functions, object-oriented is a larger package, encapsulating multiple methods in one object according to responsibilities
2. Before completing a certain requirement, first determine the responsibilities-things to be done (methods)
3. Determine according to the responsibilities different objects in different packaging methods inside the object (s)
4, and finally completed the code, so that is the order of the different objects to call different methods

Features

1. Focus on objects and responsibilities. Different objects bear different responsibilities.
2. It is more suitable for responding to complex changes in requirements. It is a fixed routine that specializes in the development of complex projects.
3. It is necessary to learn some object-oriented methods on a process-oriented basis. grammar
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_42272869/article/details/113265904