Delphi's New Feature Desired: Smart Properties declaration for Interfaces
Delphi's New Feature Desired: Smart Properties declaration for Interfaces
Currently, properties in interfaces are implemented like below:
IRecyclable = interface
function GetIsRecyclable : Boolean;
property IsRecyclable : Boolean read GetIsRecyclable; // read-only property
end;
The ugly thing is that the interface should not know how its properties will are implemented by the classes, giving more freedom for the classes that will implement it.
The new model could be something like this:
IRecyclable = interface
property IsRecyclable : Boolean; read; // read-only property
end;
or
IRecyclable = interface
property IsRecyclable : Boolean read; // read-only property
end;
Thus the classes could implement that interface as usual:
TCar = class(TInterfacedObject, IRecyclable)
private
function GetIsRecyclable : Boolean;
public
constructor Create(recyclable : Boolean);
property IsRecyclable : Boolean read GetIsRecyclable;
end;
How the class will implement the interface is sole responsibility of the class.
I am not a Embarcadero guy :D
Currently, properties in interfaces are implemented like below:
IRecyclable = interface
function GetIsRecyclable : Boolean;
property IsRecyclable : Boolean read GetIsRecyclable; // read-only property
end;
The ugly thing is that the interface should not know how its properties will are implemented by the classes, giving more freedom for the classes that will implement it.
The new model could be something like this:
IRecyclable = interface
property IsRecyclable : Boolean; read; // read-only property
end;
or
IRecyclable = interface
property IsRecyclable : Boolean read; // read-only property
end;
Thus the classes could implement that interface as usual:
TCar = class(TInterfacedObject, IRecyclable)
private
function GetIsRecyclable : Boolean;
public
constructor Create(recyclable : Boolean);
property IsRecyclable : Boolean read GetIsRecyclable;
end;
How the class will implement the interface is sole responsibility of the class.
I am not a Embarcadero guy :D
Comments
Post a Comment