[Lazarus] handy svn update script

Graeme Geldenhuys graemeg.lists at gmail.com
Mon Jul 28 14:55:03 CEST 2008






Dear Mattias ,



(A)

------------------- You said ---------------------------------------
I'm not sure, what you mean with "Main unit" is the Unit1.pas of the
project1. Do you mean the name "unit1.pas"?
--------------------------------------------------------------------

"Yes" to your above question .


Assume that from Lazarus IDE , "Project" menu , we selected "New 
Project" and "Application"
from "Create a new project" dialog .

Lazarus is opening

  (1) an editing window named "Unit1.pas" :

---b---0----------------------------


unit Unit1;                           <------------ My "main unit" means 
the 'Unit1" here .

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs;

type
  TForm1 = class(TForm)
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

initialization
  {$I unit1.lrs}

end.

---e---0-----------------------------


  (2) a form display design window with "Form1" to place components ,



  (3) an "Object Inspector" window with "Form1:TForm1" ,
 

  (4) a program as "project1.lpr" :

---b---1-----------------------------

program Project1;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Interfaces, // this includes the LCL widgetset
  Forms
  { you can add units after this }, Unit1;            <------------ My 
"main unit" means the 'Unit1" here .

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.


---e---1-----------------------------




If you allow giving other names for "project1" and "unit1" at the 
beginning ,
it may be more easy to generate programs/projects with different and 
meaningful names .

Especially when these are created in the same directory , this naming allows
easily generation of these different projects in the same directory .

At present , if it is not followed carefully one project may overwrite a 
previous project
in the same directory .


(B)

 From Lazarus IDE , from "File" , when "New Form" , "New Unit" is 
selected , the Lazarus
generating windows with "Form2" or "Unit2' with a number showing/naming 
the newly opened
parts . For the unit names , asking or allowing changing of these names 
will allow more meaningfully
given names with respect to the project concept .


(C)

At the beginning , programs or their parts , sometimes are considered 
temporary works but
over time they are becoming important tools to be used . Some design 
decisions , including names
of the parts and variables , are becoming very difficult to maintain or 
obstacles in front of the
development and they are requiring re-names which sometimes are causing 
nightmares .

Therefore allowing the user at any point to be able to rename 
automatically generated parts by
the Lazarus will allow a more easy development process .


It is obvious that , a programmer may also use the default names . 
Personally I do NOT prefer
to use such common names because over time they may become important 
parts of some other programs .
Why should I loose time for re-naming and a complete whole testing ?


(D)

My another suggestion is about style of program part generation because 
at the beginning
( more than 20 years ago ) I was using the above style , but now I am 
using the following style
because , for large programs , the above style is causing difficulties 
for maintenance and patching
parts into sources or removing some parts of them . The IDE editor is 
NOT saying that
"You can not write programs longer than ... lines" .


 


unit Unit1;
                          
{$mode objfpc}
{$H+}

interface

uses
  Classes,
  SysUtils,
  LResources,
  Forms,                <---- This style allows insertions between unit 
names , and
  Controls,                   erasing of unnecessary names easily .    
  Graphics,
  Dialogs;

type TForm1 = class(TForm)   <------------ This style allows searching 
by grep , etc. and/or listing of types .
  private
    { private declarations }
  public
    { public declarations }
  end;

var Form1: TForm1;           <------------ This style allows searching 
by grep , etc. and/or listing of variables .

implementation

initialization
  {$I unit1.lrs}

end.


A similar style may be used for constants :


NOT :


  Const
       a = '?' ;


BUT

  Const a = '?' ;


"Type" , "Var" , Or "Const" for EACH of the names because of searching , 
listing these entities by grep like
tools :


NOT :

  Var
    a , b , c , d : Integer ;

BUT

  Var a : Integer ;
  Var b : Integer ;
  Var c : Integer ;
  Var d : Integer ;

( Readability and maintainability of programs is MUCH and MUCH more 
important than
  any other considerations such as "Compile Time" etc ( as microseconds 
or less ) ,
 "Number of  PUNCHED cards handled " (  in OLD GOOD days  ) , etc . )


For the program :

program Project1;

{$mode objfpc}
{$H+}

uses

  {$IFDEF UNIX}
  {$IFDEF UseCThreads}            <----- for easy readability .

  cthreads,

  {$ENDIF}
  {$ENDIF}

  Interfaces, // this includes the LCL widgetset
  Forms
  { you can add units after this },
            
  Unit1;                          <----------------- for insertion of 
names before this name .        

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.


If you generate your templates in the above style , in the long range
the programmers will find them more useful with respect to present style .

-------------------------------------------------------------


Thank you very much ,

Mehmet Erol Sanliturk






More information about the Lazarus mailing list