When a property is backed directly by a field (without a getter and/or a setter) and this field is never accessed directly, the code can be further simplified by dropping the field declaration altogether.
An example of such code would be:
type
TMyClass = class
private
FData: integer;
public
property Data: integer read FData write FData;
end;
This code can be simplified to:
type
TMyClass = class
public
property Data: integer;
end;
Smart will still create a field inside the TMyClass object, but this field will be aonymous and not accessible directly from the code.
Note: This type of properties cannot be used in external classes and lasses inheriting from the JObject class.
No comments:
Post a comment