Programmers who are not object-oriented are not good programmers
I am familiar with object-oriented! ! ! !
Basic concepts of object-oriented
Object-oriented practice in PHP
ObjectOrientedObject
(Object Oriented)? Object
(Object)? Oriented
What is an
Everything in the world is an Object
- a person, a car, a A plane, a table - All visible things are
objects
- All invisible objects
(abstract things) can also be objects An example of an abstract concept
object
- table A table A person (NBA player)
Running and jumping abilities are very important. Playing basketball involves many skills such as dribbling, shooting, dunking, and passing.
NBA is the abbreviation of American professional basketball. NBA players all belong to one team.
A person (female anchor)
A female anchor is a host who organizes concerts and parties online. They usually use a stage name online. During the online concert, the female anchor will sing songs for everyone. The basic composition of
object
includes two partsobject
component elements? It is the data model of object
, used to describe the data of object (such as several legs of a table, desktop, The length and width are both the data model of the table)? Also known as the attributes of the object
, or the member variables of the objectThe behavior of the object
? is the behavior model of the object, used to describe the
object What can be done (objectbehavior, such as table movement, NBA players dribbling, passing and jumping, female anchors singing and interacting with the audience)? Also known as objectmethods
Characteristics of objects
? Every object is unique (for example, NBA player James is James, unique.)
? Object is a specific thing, and its function is to complete a specific function (for example, the specific function of NBA player is to specifically play For basketball, the female anchor specializes in singing at concerts)
? Objects can be reused (for example, after James has finished playing this game, he can play the next one, and after dribbling this time, he can also play the next time)
Basic concepts of
object-oriented
What is
object-oriented
Oriented means always keeping objects in mind when programming
OrientedObjectprogramming means that when programming, the programming structure (data organization method) is stored through the structure of
objectProperties, methods
Why use
? The description method of
objects is more in line with the real world and is conducive to the understanding of large-scale business.
In the process of programming, when analyzing the world from the perspective of objects, it can shorten the distance between programming and the real world
oriented Object
oriented to Object is to store all the problems to be solved in life in the form of The basic idea of object-oriented
object? Attributes (athlete’s height/weight/age)? Methods (running/jumping/throwing/ Dunk) The interaction between the
object
and the
object is completed through the mobilization of methods? Method (James passes the ball to Wade, and Wade completes a dunk)
The first step: Identify the object
-Any entity can be recognized as an object
The second step: Identify the attributes of the object-the data stored in the
object Identified as attributes-For different business logic, the data of concern is different, and the attributes stored in the
objectare also differentStep 3: Identify the behavior of the
object-
objectchanges in its own attribute data-
Example of object interacting with the outside
object - table Examples of
objects--NBA players
Basic principles of Object-oriented(also the Basic principles of programming)objects
are high inside (high cohesion has everything, no arms or legs)? Object
is only responsible for a specific function (the function can be big or small, for example, singing is not a necessary skill, nor is playing basketball) )? All object
related content is encapsulated into object internal object
is low-coupled to the outside world (low coupling is particularly important, the dependencies between each other are particularly small, and code reusability is high)- The external world can See some properties of the object
(not all) such as the age of NBA players, etc.- The outside world can see that the object
can do certain things (not all)
The above introduces PHP object-oriented programming - the basic concepts of object-oriented DAY 1, including aspects of content. I hope it will be helpful to friends who are interested in PHP tutorials.