Search code examples
coding-stylelazarus

Lazarus coding style guide


Style Guide?

Other than http://wiki.freepascal.org/Coding_style is there a style guide that represents the style followed by a notable and large body of work in Lazarus ( and/or FPC and/or Delphi) or some sort of widespread concensus.

Example

I'm looking for things that say something such as

  • Names of literal constants should be in all uppercase.
  • Names of variables should use camelCase with initial lowercase
  • Indent a begin on the line after an if

The above is just an example. I'm aware of well-supported conventions in languages like Java and Perl but not of a predominant convention for programs written using Lazarus or Delphi.

Purpose

My intent is

  • Try to adopt a common style for all the code I write
  • Have this style not be too much of a surprise for the majority of programmers who might one day read it.

I'm not working in a business that has established standards.


Solution

  • As a good detailed style guide I'm considering the Object Pascal Style Guide by Charles Calvert. It's for Object Pascal which the Free Pascal is a child of. In fact, most of the FPC units respect the rules mentioned there.

    This article documents a standard style for formatting Delphi code. It is based on the conventions developed by the Delphi team.