Difference between revisions of "DesignGuidelines"

From Lazarus wiki
Jump to navigationJump to search
(→‎Coding Guidelines for Lazarus: updated link to cvs)
(→‎Coding Guidelines for Lazarus: merged changes from the cvs version)
Line 6: Line 6:
 
* Since one style is easier to read, Lazarus follows the Borland Coding style guide lines. Of course, almost anyone will find some points there, that are arguable less readable than other styles. That's ok, just try to follow at least 90%.
 
* Since one style is easier to read, Lazarus follows the Borland Coding style guide lines. Of course, almost anyone will find some points there, that are arguable less readable than other styles. That's ok, just try to follow at least 90%.
 
* Try to avoid unit circles. This makes it easier to navigate and when unit is growing allows to split it.
 
* Try to avoid unit circles. This makes it easier to navigate and when unit is growing allows to split it.
* Minimize the number of calls from Interfaces to LCL, when performing an action requested by the LCL.
+
* Minimize the number of calls from Interfaces to LCL, when performing an action requested by the LCL. The interfaces only notify the LCL, never forces something. The LCL decides.
 +
** Naming convention:
 +
*** Notifications for TControl decendants should be named CNxxx.
 +
 
 
* All code must work with all checks (range, io, overflow, stack) on. Besides that this helps debugging, some users put these checks into their fpc.cfg, so they are applied to whole lazarus. Including packages and examples.
 
* All code must work with all checks (range, io, overflow, stack) on. Besides that this helps debugging, some users put these checks into their fpc.cfg, so they are applied to whole lazarus. Including packages and examples.
  
 
;New files:
 
;New files:
 
* Every file should start with a header containing the license and a few lines describing the content.
 
* Every file should start with a header containing the license and a few lines describing the content.
 
+
* Pascal sources should have lowercase filenames (.pas, .pp, .inc, .lfm, .lrs)
  
 
;Include files:
 
;Include files:

Revision as of 12:44, 18 July 2005

Coding Guidelines for Lazarus

This is for lazarus developers:

Coding style
  • Since one style is easier to read, Lazarus follows the Borland Coding style guide lines. Of course, almost anyone will find some points there, that are arguable less readable than other styles. That's ok, just try to follow at least 90%.
  • Try to avoid unit circles. This makes it easier to navigate and when unit is growing allows to split it.
  • Minimize the number of calls from Interfaces to LCL, when performing an action requested by the LCL. The interfaces only notify the LCL, never forces something. The LCL decides.
    • Naming convention:
      • Notifications for TControl decendants should be named CNxxx.
  • All code must work with all checks (range, io, overflow, stack) on. Besides that this helps debugging, some users put these checks into their fpc.cfg, so they are applied to whole lazarus. Including packages and examples.
New files
  • Every file should start with a header containing the license and a few lines describing the content.
  • Pascal sources should have lowercase filenames (.pas, .pp, .inc, .lfm, .lrs)
Include files
  • should start with the {%MainUnit } directive


Packages
  • should have an .lpl entry in packager/globallinks/


Dialogs (modal forms)
  • Close on Escape (if key not used otherwise)
  • Define default button and Return activates it (if key not used)
  • Medium to complex dialogs should be resizable and size is stored


Main Menu Items
  • Should have a key in keymapping.pp



Latest version can be found in cvs. Proposals for improvement can be added to talk page (discussion).