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…

AJAX: What it is and how to use it in Scriptcase

Hello, in this post we will conceptually understand the AJAX event and how use  inside the Scriptca...

What advantages for a company in adopting a low-code tool?

Let's understand how low-code tools have become a facilitator in the web development process as they...

How to implement A2F using Swivel in a Scriptcase application

I want to start talking about Swivel, Swivel is a provider of authentication solutions who have been...

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.