Attributes can be thought of as special auxiliary domains that can modify and execute code on the data in a class. For a component, a property is the contents of a column that is listed in the Object Inspector window. The following example defines a simple object with attributes
Tmyobject = Classprivate somevalue:integer; Procedure Setsomevalue (Avalue:integer);p ublic property Value:integer Read somevalue write setsomevalue;end; Procedure Tmyobject.setsomevalue (Avalue:integer); begin If somevalue <> avalue then somevalue: = Avalue; End
Tmyobject is an object that contains the following: a domain (the number of integers called somevalue), a method (a process called a setsomevalue), and a property called value
The function of the Setsomevalue procedure is to assign a value to the Somevalue field, and the Value property does not actually contain any data. Value is a secondary domain of the somevalue domain, and when you want the value in values, it reads the value from Somevalue, and when you try to set a value on the Values property, value calls Setsomevalue to the Somevalue setting value.
There are two advantages to this:
1) First, using a simple variable allows external code to access the object's data without needing to know the implementation details of the object
2) Second, methods such as Setsomevale can be overridden in a derived class to achieve polymorphism
Delphi Object-oriented properties