Abstraction is one of the most important concepts of object-oriented programming. From it comes from how objects are drawn in the form of classes, their characteristics are idealized as attributes and functionality as methods.

The concept is based on the following: from a real situation, the subjects involved, inanimate or not, are converted to the code in the form of objects. We can use the example of a lynx that needs to be registered in a zoo system.

OOP

We will work with the example mentioned above using the PHP language. First, then, let’s create the “Lynx” class.

 

class Linx{

}

 

Our object is now created. Below we will implement some attributes which are nothing more than the subject’s features.

class Linx{

private $name;

private $weight;

private $id_ident;

}

Attributes can also consider information as personal documents and unique identifiers. The variables in this case are declared as private so that treatment of them is done using another concept of object-oriented programming: encapsulation.

Created the object and its attributes, it is now necessary to create the features in the form of methods.

 

class Employee{

private $name;

private $weight;

private $id_ident;

 

function Register ()

{

//code here

}

 

function Delete()

{

//code here

}

 

}

 

With the created methods, it is now possible to register and delete any Lynx that arrives at the zoo. These would be the most basic methods. Thus, many others may be created in order to make the most complete object.

The real-world objects abstraction capacity for programming is essential for the development of activities of any programmer. Understanding the concept and applying it properly will save hours of development and ensure greater productivity to the environment.

You might also like…

PROCESAMIENTO AJAX EN SCRIPTCASE

Ajax en los formularios de Scriptcase puede usarse para recargar un campo de tipo de select basado e...

IMPORTAR IMAGENES DE LA BASE DE DATOS Y UTILIZAR CLASES DE BOOSTRAP

Como muchas personas ya saben, Bootstrap es una biblioteca de front-end libre y de código abierto p...

TENDENCIAS DE DESARROLLO WEB PARA 2017

Usted verá en este post tendencias para 2017 en Diseño Web, en el medio digital y en el desarrollo...

Comment this post

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at sales@scriptcase.net. Learn more about our Privacy Police.