[Lazarus] Challenge of converting a Delphi project

Juha Manninen juha.manninen at phnet.fi
Wed May 5 13:34:09 CEST 2010


Samuel Herzog wrote:
> They way I format the my source-code and and ess-model is a good example why 
such things are important
> 
> Original:
> ******
> procedure TessConnectPanel.DblClick;
> var
>   found: TControl;
> begin
>   inherited;
>   found := FindLCLWindow(Mouse.CursorPos);
>   if Assigned(found) then
>   begin
>     FindManagedControl(found);
>     if found <> Self then
>       TCrackControl(found).DblClick;
>   end;
> end;
> 
> The same with my formating-style:
> **************************
> procedure TessConnectPanel.DblClick;
> var
>   found: TControl;
> begin
>   inherited;
>   found := FindLCLWindow(Mouse.CursorPos);
>   if not Assigned(found) then exit;
>   FindManagedControl(found);
>   if found = Self then exit;
>   TCrackControl(found).DblClick;
> end;
> 
> Much better to read, and you see at once, that "FindManagedControl" looks 
strange!
> 
> There is only one rule that applies for all programmer's! We read source-
code from top-down. 
> That's why I try to avoid "else"-statements.

Thanks, I took out the useless FindManagedControl call. It was already in the 
original EssModel code.

I must say I like the original indented formatting more.
Indentation carries information by itself. Your formatting loses that 
information. ... and there was no "else"-statements.

Anyway, it is a minor thing.


Regards,
Juha




More information about the Lazarus mailing list