The concept of attribute and property raises many questions for those working with object-oriented programming, because conceptually they would be equal to one another.

According to Fowler (2005), a property is a structural characteristic of a class, i.e, it effectively determines what the object is. But the other attribute can also represent what the class can do.

atributo_php

To make it clear to understand, let’s go to a practical example: the class ’employee’ has the property ‘name’ and the attribute ‘card’, which is represented in this case by a second class that saves the employee’s card information.

class Employee

{

$ Name = “”;

$ Card = new Card();

}

The property ‘Name’ is represented by a string, as the ‘Card’ attribute is represented by an object and that’s the main difference between them.

Whenever a piece of information is handled in a straightforward manner, for example, an integer value or string, it may be considered as a property. However, when it is represented by an object that has properties, attributes and methods, then it will be treated as an attribute.

This difference sometimes subtle, goes unnoticed in many analyzes. When performing the description of a process, it is necessary to assess whether the nomenclature used is correct, within the common knowledge of the team.

Finally, we can say that the property identifies the characteristics that determine what actually is the object, and the attribute can define what it is and also its features, which in turn are inherited from a secondary object that rules that attribute.

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.