-
Notifications
You must be signed in to change notification settings - Fork 35
Closed
Labels
completedWork has been completed on this issue and changes have been committed to `develop` branch..Work has been completed on this issue and changes have been committed to `develop` branch..refactoringThis issue requires refactoring only, not a change in functionalityThis issue requires refactoring only, not a change in functionality
Description
Line 109 in 93bc8df
procedure TCSSSelector.AddProperty(const CSSProp: string); |
Convert TCSSSelector.AddProperty
to be fluent and to return its Self
instance to enable chained method calls.
Presently, this method is usually called in with statements. That's a code smell that would best be refactoring out. Making this proposed change would make the proposed refactoring easier.
For example, refactoring
with CSSBuilder.AddSelector('a.command-link') do
begin
AddProperty(TCSS.ColorProp(clCommandLink));
AddProperty(TCSS.FontStyleProp(cfsItalic));
AddProperty(TCSS.TextDecorationProp([ctdNone]));
end;
Without the proposed change would result in something like:
var
Sel: TCSSSelector;
begin
Sel := CSSBuilder.AddSelector('a.command-link');
Sel.AddProperty(TCSS.ColorProp(clCommandLink));
Sel.AddProperty(TCSS.FontStyleProp(cfsItalic));
Sel.AddProperty(TCSS.TextDecorationProp([ctdNone]));
end;
While with the fluent version we could write
begin
CSSBuilder.AddSelector('a.command-link')
.AddProperty(TCSS.ColorProp(clCommandLink))
.AddProperty(TCSS.FontStyleProp(cfsItalic))
.AddProperty(TCSS.TextDecorationProp([ctdNone]));
end;
Which doesn't require a local variable and is more readable.
Metadata
Metadata
Assignees
Labels
completedWork has been completed on this issue and changes have been committed to `develop` branch..Work has been completed on this issue and changes have been committed to `develop` branch..refactoringThis issue requires refactoring only, not a change in functionalityThis issue requires refactoring only, not a change in functionality