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.

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.

Check out more content on our blog!
Learn all about Scriptcase.

By ,

May 7, 2015

a

You might also like…

No-code: Ease or Trap? What no one tells you about creating without coding

With the popularization of No-code and Low-code platforms, application development has reached a po...

Top 10 Rapid App Development Tools You Need to Know

In this highly fast-moving digital world, rapid application development tools must be available to ...

You might also like…

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.