[OOP]: Object-oriented programming is what?


Posted on 2015-08-18 10:36:40

Advanced PHP - Once you see their entries in the PHP Essential sure you understand the basics of PHP Programming, right? Today I ...

Advanced PHP - Once you see their entries in the 
PHP Essential sure you understand the basics of 
PHP Programming , right? Today I will introduce and guide you to understand the knowledge of advanced php programming. First in order for you to understand and absorb the articles behind, then today I'll show you a brand to the concept is not far back for you yet had the programming but maybe new to what you initially learn. That is the concept of "object oriented programming is what? "
1. Object Oriented Programming is? 
Object-oriented programming ( OOP for short, from the English object-oriented programming ), also known as object-oriented programming, the programming techniques object technology support. OOP is seen as helping to increase productivity, simplify maintenance complexity as well as expansion by enabling software developers to focus on objects at higher software. Also, many people feel that OOP more receptive to new people learn about programming than previous methods. In brief, this is a concept and as an attempt to mitigate the manipulation coding for programmers, allowing them to create applications that external factors can interact with the program like the interaction with physical objects. The objects in an OOP language is the combination of code and data that they are seen as a single unit. Each object has a separate name and all references to objects that are conducted through its name. Thus, each object is capable of receiving the notification, data processing (inside of it), and sent out or respond to other objects or to the environment. 
  2. The basic properties of object-oriented programming Object (object): 
The data and indicators are combined into a complete unit make up an object. This unit is equivalent to a subroutine and so the object will be divided into two main parts: parts method (method) and the attributes (property). In fact, the method is the function of the object and its attributes are variables, parameters, or intrinsic constants of an object (in other words, a data set of intrinsic properties form of subjects). The method is a means to use an object in the attributes object describes the properties. The methods and properties often tied to the actual characteristics and use of an object. In fact, the subjects are usually abstractions over the definition of the class (class). Gather the existing value of the properties make up the state of an object. Each method or the internal data each with defined properties (by the programmer) is considered a unique character of subjects. If no mistake, the set of characteristics referred to as properties of the object. Object-oriented programming is a programming method has the following main features: 
Abstraction (abstraction): This is the program's ability to ignore or not pay attention to some aspect of the information that is directly worked up, meaning it has the ability to focus on the core needs set. Each object serves as a "real mail" can complete an internal job, report, change its status and contact with other objects without needing to know how to object manipulation is carried out. This property is commonly known as the abstraction of data. Abstract was reflected by an original object can have a number of characteristics common to many other objects as an extension of it, but the original object itself can no enforcement measures . This abstract is usually determined in concept called abstract classes or abstract base class or. Encapsulation (encapsulation) and concealed information (information hiding): This feature does not allow users to change the object's internal state of an object. Only the intrinsic method of object allows to change its status.Allowing external environment impact on the internal data of an object in a way that totally depends on who wrote the code. This is the nature ensures the integrity of the object. 
Polymorphism (polymorphism): Shown through the sending of messages (message). Sending these messages can be compared as to call functions inside of an object. The method used for a reply message will depend on the object to which the message is sent to will have different reactions. Programmers can define a characteristic (such as through the name of the method) for a variety of objects close together but in the exercise, use the same name that the execution of each object will automatically occur corresponding properties of each object without being confused. For example when two objects define "hinh_vuong" and "hinh_tron" there is a common method is "chu_vi". When this method is called if the object is "hinh_vuong" it will be calculated according to a different formula for the object as "hinh_tron". 
 Inheritance (inheritance): This feature allows an object may be available the properties that other objects made ​​through inheritance. This allows the audience to share or expand the features available without conducting redefined.However, not the language of object-oriented properties also. 
  3. The concept involves the programming language of modern OOP Class (class) 
A class is defined as a data type includes attributes and methods that are defined in advance. These are abstractions of objects. An object will be established when it is made from a layer materialize. Unlike the conventional type, a class is a unit of (abstract) includes a combination of methods and attributes. To have an object (which may be viewed as a variable) operation, the chemical entity will be able to include the installation of the initial value of the properties as well as the registered memory, which This task is usually delegated to the method known as "machine structural" (constructor) or constructor. Conversely, when an object belongs to a class no longer used, it can also have a method to handle calls "machine of destruction" (destructor) or destructor. Thus, to get the objects, the OOP programmers need to design classes of objects by building the properties and methods that have their own unique properties. Each method or attribute of a class full name is also known as a member (members) of the class. 

Subclass (subclass) Subclass is an ordinary class but has inherited nature or part of the property of a different class. Classes that share the successor called parental class (parent class). Abstract classes or abstract base class (abstract class) The abstract class is a class that can not be turned into a real object is utilitarian. This class is designed to create a class that features extensive but the class itself has no meaning (or not enough sense) to be able to write code for conducting chemical entity. Example: Class "hinh_phang" is defined not have internal data and methods only (intrinsic function) "tinh_chu_vi", "tinh_dien_tich". But because this hinh_phang class yet been fully determined its features (namely the intrinsic variables are the coordinates of the vertices if the polygon, the radius and center coordinates if the circle, ...), so it can only be written into an abstract class. Then, programmers can create subclasses such as class "tam_giac" class "hinh_tron" class "tu_giac", .... And in this the person coding sublayer will provide internal data (such as variable as the radius r inner and the intrinsic constant Pi to class "hinh_tron" and then write code specific to the modes " tinh_chu_vi "and" tinh_dien_tich "). 

Method (method) As the intrinsic function of a class (or an object). Depending on the features that programmers assigned to, a method can only be called within other functions of the class, may allow the statement referred to its outside layer, or only allow the related class Special systems as subclass relations, and relations friend (friend) is allowed to call it. Each method can have the return type, we can pay the classical type or return a type of a class has been defined previously. Another name of the method as a function of a class member. It also defines more specifically some type of method: Constructor (constructor) function is used to set the initial values ​​for the variables intrinsic and sometimes used to declare the use of memory. The function cancel (destructor) is a function used to clean the mind and cancel the name of an object after you're done, which can include intrinsic delete pointer and returns the memory section which subjects were used. In some cases, the destructor or constructor can be automated by OOP languages ​​such as Visual C ++ case, C #. Utility (utility) is the only operating function inside of a classroom environment that does not allow outside call. These functions may be mediate internal calculation of an object is considered no need for the outside world know what is the object. 
Attribute (attribute) Properties of a class consists of variables, constants, or intrinsic parameters of the class. Here, the most important role of the properties are variables because they can be changed during operation of an object. The properties may be determined by the type and style they can be the classical type or that is a pre-defined classes. As already stated, when a class was actually materialize into concrete objects gathered in the values ​​of internal variables as the state of the object. Like the case of methods, depending on who write code, internal variables can only be used within the methods of the class itself, may allow the statement outside the class, or just allow the class special relationship as the class relations (and relational friend (friend) in C ++) is allowed to use it (or change its value).Each attribute of a class known as data members of that class.

Entity (instance) Chemical entity (instantiate) the declaration process to have a name (can be viewed as a transformer) become an object of a certain class. One class was conducted after chemical entity for a specific object called an entity. Or, vice versa an entity is an individual object of a predetermined class. As usual variables, the two entities of the same class may have different internal states (determined by the current value of the internal variables) and therefore completely independent of each other without request nothing special from the programmer. 
Public (public) Public is a property used to assign to these methods, internal variables, or the layers that they can be cleared, the programming has allowed external commands as well as other objects are allowed to use it . For example: In C ++ declaration public: int my_var; then turn my_var two properties are public properties and is an integer both properties characteristic of the variable component makes it possible my_var use or change its value (by the statement) everywhere outside and inside the classroom. 
Private (private) Privacy is an expression of the strongest closed nature (of a characteristic or a class) When using the properties assigned to a variable, the variable method or methods that may be used only within the class that they are defined.Any attempt to use them from outside via voice commands from the subclasses will be denied or error. 

Conservation (protected) Depending on the language, there will be some minor differences in the understanding of this nature. Overall this is that when properties which used to apply to the method, the internal variables, or classes, only within that class or its subclasses (or inside a package as in Java) are allowed to call or use the method, variable or class. Compared to private property is more widely conserved in terms of sharing data or functions. It allows some cases used to the characteristics of a class (from a subclass instance). Note: The public nature, privacy and conservation is sometimes used to indicate how a subclass inherits a parent class as in C ++.

Multiple inheritance (muliple inheritance) This is a feature that allows a subclass capable direct successor to multiple other layers. A few points to note when writing code using multiple inheritance properties: When you want to have a sub-class inherits from multiple samples, then these classes must be independent and in particular the names of the data or functions that enable legacy must have different names to avoid errors "ambiguilty". Since then the software will not be shifted identified subclass will inherit the name of the sub-template class. Not fertilizers OOP language classes also support this feature. In addition to the above concepts , depending on the language, there may be separate functions granted OOP added. 

Conclusion: This article only focuses on its owner theory. Next article I will introduce you to the basic syntax of object-oriented programming in php.