Ec (2); object-oriented programming is designed to provide solutions for large software projects, especially projects that involve multiple people. when the source code grows to 10 thousand lines or even more lines, every change may lead to unwanted side effects. this happens when modules form a secret alliance, just like Europe before the First World War. haohappy Note: The correlation between modules is too high, and the mutual dependence is too strong. when a module is updated, other modules must also be updated. imagine that a module used to process logon promised a letter "script" ec (2); "script"
Object-Oriented Programming is designed to provide solutions for large-scale software projects, especially projects with multi-person cooperation. when the source code grows to 10 thousand lines or even more lines, every change may lead to unwanted side effects. this happens when modules form a secret alliance, just like Europe before the First World War.
// Haohappy Note: The correlation between modules is too high and the dependency between modules is too strong. If a module is changed, other modules must also be changed.
Imagine that a login processing module promised a credit card processing module to share its database connection. of course, the starting point is good, saving money for connecting to another database. however, sometimes, when the login processing module changes the name of a variable, the protocol between the two may be broken. this causes an error in the processing of the credit card module, which leads to an error in the processing module. soon, all irrelevant modules in the system may fail.
Therefore, I think it is a little dramatic that most programmers are grateful for coupling and encapsulation. coupling is a measure of the degree of reliance between two modules. the less coupling, the better. we hope to extract a module from an existing project and use it in another new project.
We also hope to make large-scale changes within a module without worrying about the impact on other modules. the encapsulation principle can provide this solution. modules are regarded as relatively independent, and data communication between modules is performed through interfaces. modules do not use their variable names to snoop on another module. They use functions to send requests politely.
Encapsulation is a principle that you can use in any programming language. in PHP and many process-oriented languages, it is tempting to be lazy. nothing can prevent you from using modules to build a hypothetical WEB. object-Oriented programming is a method that prevents programmers from violating encapsulation principles.
In object-oriented programming, modules are organized into objects. these objects have methods and attributes. from an abstract point of view, a method is an action of an object, and a property is a feature of an object. from the programming point of view, the method is a function and the attribute is a variable. in an idealized object-oriented system, each part is an object. the system consists of links between objects and objects through methods.
A class defines the attributes of an object. if you are baking a set of cookies, the category will be a cookie machine. class attributes and methods are called members. people can express data members or method members.
Each language provides a different way to access objects. PHP borrows concepts from C and provides a data type to include functions and variables under an identifier. When PHP was initially designed and even when PHP3 was developed, PHP was not intended to provide the ability to develop large projects with over 0.1 million lines of code. With the development of PHP and Zend engines, it is possible to develop large projects. However, no matter how large your project is, writing your scripts using classes will allow code to be reused. This is a good idea, especially when you are willing to share your code with others.
The idea about objects is one of the most exciting concepts in computer science. It is hard to grasp it at first, but I can assure that once you grasp it, it will be very natural to think with it.