Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2002-11

Code pattern question

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michal Bukovjan

Hi,

when looking at the code of Lazarus (not LCL), I found that quite often when we create a control (say, in constructor), we do it quite often via code like:

AControl:= TControl.Create(AOwner)
with AControl do begin
   Parent ...
   Name:= 'LongControlName';
   Visible:= true;
end;

Is setting up Name and Visible (to true) necessary?

'Name' does not make sense for controls created like this and visibility is always true by default.

Is there any reason, or can this be cleaned up (over time, not necessarily now), (reducing Lazarus size somewhat).

Michal

Reply by email

Mattias Gaertner
to Michal Bukovjan
Show quoted text 20 lines
Hi, when looking at the code of Lazarus (not LCL), I found that quite often when we create a control (say, in constructor), we do it quite often via code like: AControl:= TControl.Create(AOwner) with AControl do begin Parent ... Name:= 'LongControlName'; Visible:= true; end; Is setting up Name and Visible (to true) necessary? 'Name' does not make sense for controls created like this and visibility is always true by default. Is there any reason, or can this be cleaned up (over time, not necessarily now), (reducing Lazarus size somewhat).

It helps debugging, profiling and someday to turn it into a lfm file. For example: When the gtk calls one of our callbacks, you can see 'CompilerPathComboBox:TButton' instead of 'TButton' and so you know instantly what is going on.

The visible is set to true for historical reasons, when visible was false as default. These lines can be deleted.

But I doubt that deleting one thousand lines will reduce much. We produce this amount every week.

Mattias

Reply by email