"Getting Started with PHP object-oriented (OOP) programming" 2. What is a class, what is a relationship between objects, classes, and objects

Source: Internet
Author: User
Tags getting started with php

Class Concept: A class is a collection of objects that have the same properties and services. It provides a unified, abstract description of all objects that belong to the class, including two main parts of properties and services. In an object-oriented programming language, a class is a stand-alone program unit that should have a class name and consist of two main parts: a property description and a service description.

Object concept: An object is an entity used to describe an objective thing in a system, which is a basic unit of a system. An object consists of a set of properties and a set of services that operate on that set of properties. From a more abstract point of view, an object is an abstraction of a problem domain or something in the implementation domain that reflects the information and the role that the thing needs to be saved in the system; it is a set of attributes and a wrapper for a set of services that have permission to manipulate these properties. The objective world is made up of the connections between objects and objects.

The relationship between a class and an object is like the relationship between a mold and a casting, and the instantiation of a class is the object, and the abstraction of a class object is the classes. The class describes a set of objects that have the same attributes (attributes) and the same behavior (methods). Above is probably their definition, perhaps you are just contact with the object of the friend, do not be confused by the concept of things, give you a column, if you go to Zhongguancun to buy a few assembled PC, to where you first step to do, is not installed engineers and you sit together, According to the information you provide with you to complete an installed configuration single Ah, this configuration can be imagined as a class, it is a piece of paper, but it is recorded on the PC you want to buy information, if you buy 10 machines with this configuration, then these 10 machines, are based on this configuration single, So the 10 machine is a type, it can be said to be a kind of. So what is the object, the instantiation of the class result is the object, with this configuration single configuration (instantiation) of the machine is the object, we can operate the entity, 10 machines, 10 objects. Each machine is independent, can only show that they are the same class, to one of the machines do any action will not affect the other 9 machines, but I modify the class, that is, in this configuration list with one or fewer accessories, then the installed 9 machine has changed, this is the relationship between classes and objects (class instantiation result is the object).


This article is from the "Anping notes" blog, so be sure to keep this source http://anping.blog.51cto.com/10316899/1952679

"Getting Started with PHP object-oriented (OOP) programming" 2. What is a class, what is a relationship between objects, classes, and objects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.