Object-oriented basic concept object-oriented programming language mescaline-object-oriented programming of Lai JS

Source: Internet
Author: User
Object-oriented consists of 3 parts: Object oriented Analysis,ooa, object-oriented design (objects oriented Design,ood), and object-oriented programming (objects oriented Programming,oop). Two important concepts of object-oriented programming are classes and objects.

Class
A class is a collection of variables and methods that act on these variables, and things have their own properties and methods that allow different substances to be separated. For example: People with height, weight, fat and thin and skin color and other properties, but also can eat, learn, walk and other activities, these activities can be said to be a human function. A person can be seen as a class in a program, so a person's height can be likened to a property in a class, and walking can be likened to a method in a class. That is, a class is a collection of properties and methods, the core and foundation of object-oriented programming, and the ability to effectively manage the fragmented code used to implement a function.
Object
A class is an abstract model with a certain function, and in practice it is necessary to instantiate the class so that the concept of the object can be introduced. An object is a product of a class that is instantiated and is an entity. Still take people as an example, "Yellow man is human" this sentence is not wrong, but conversely, "people are yellow people", this sentence must be wrong. Because people besides the yellow people also have black, white people and so on. Then the "Yellow Man" is an instance object of the "Man" class. You can understand the relationship between an object and a class: The object is actually a kind of flesh and blood that can be touched.
Three main features of object-oriented programming
Object-oriented programming has three characteristics of encapsulation, inheritance and polymorphism. Encapsulation can effectively avoid code coupling in program design, inheritance can effectively utilize code resources, and polymorphism can effectively improve the reusability of code.
Encapsulation:
Encapsulation can also become information hiding, that is, to separate the use and implementation of a class, only to retain a limited number of interfaces (methods) and external relations. For developers who use this class, it is only necessary to know how this class can be used, without worrying about how the class is implemented. This allows developers to focus on other things better, while avoiding the inconvenience of inter-dependencies between programs.
Inheritance:
Inheritance is that derived classes (subclasses) automatically inherit properties and methods from one or more base classes (the parent class), and can override or add new properties or methods. Inheriting this feature simplifies the creation of objects and classes, and the reusability of the added code. Inheritance is divided into single inheritance and multiple inheritance, PHP currently only supports single inheritance, that is, a subclass has only one parent class.
Polymorphism :
Polymorphism refers to different objects of the same class, and using the same method can obtain different results, and this technique becomes polymorphic. Polymorphism enhances the flexibility and reusability of software.
If you do not have a hand, you should make a lot of mistakes.

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above introduces the basic concept of object-oriented, including the object-oriented aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Related Article

    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.