Process-oriented: write code from top to bottom according to business logic
Process-oriented programming focuses on how
Realize the requirements step by step from beginning to end
According to the development requirements, the function code is encapsulated into one function after another
The completed code is to call different functions in sequence
Features:
Focus on steps and processes, not on division of responsibilities
Complicated requirements lead to complex code
It is difficult to develop complex projects
Object-oriented (OOP): Bind variables and functions together, and encapsulate them by category. Each program is only responsible for the category assigned to itself, enabling rapid development and reducing duplication of code
Object-oriented programming, the focus is on who does it
First determine the responsibilities
Determine different objects according to their responsibilities, and encapsulate different methods inside the objects
The code is to call the corresponding methods of different objects in sequence
Features:
Focus on objects and responsibilities, different objects assume different responsibilities
It is more suitable for responding to complex demand changes, and it is specially designed to deal with the development of complex projects, providing fixed routines
Need to learn some object-oriented syntax on the basis of process-oriented
classes and objects
A class is a general term for a group of things with the same characteristics or behaviors, and is abstract.
A feature is actually a variable, which we call an attribute in a class
A behavior is actually a function, which we call a method in a class
A class is actually an abstract concept composed of attributes and methods .
An object is a concrete existence created by a class, which can be used directly
The object created by which class has the properties and methods defined in which class
Object Oriented Basic Syntax
Define class: how to define class name
Define the class name according to the current needs
Use class to define a class
class Class name: Class names generally need to follow the big hump nomenclature, and the first letter of each word needs to be capitalized