PDA

View Full Version : Style guide



Harry Hunt
03-12-2003, 05:33 PM
This is not a question but a suggestion:

When you write code that you intend to share with other people or if you work in a team, it's a good idea to follow the official Borland Object Pascal style guide. Most people have read the style guide and a lot of people code accordingly but I still see a lot of people capitalizing reserved words or using all caps, people who ident with single spaces or with tabs, etc. ...

Of course it doesn't make you less of a good programmer if you don't follow the style guide, but it's just easier to read for other people if you do.

The official Borland Object Pascal style guide:
http://community.borland.com/soapbox/techvoyage/article/1,1795,10280,00.htm

Useless Hacker
03-12-2003, 05:46 PM
Yes sir! :salute:

Alimonster
03-12-2003, 06:06 PM
Good call -- I've been meaning to bring this up but keep forgetting.

I've made this thread a sticky.

Snape
05-12-2003, 02:21 PM
There's also a delphi-jedi project which does the formatting for you.
http://jedicodeformat.sourceforge.net/

siim
06-12-2003, 09:31 AM
8.1.3 Array declarations
There should always be a space before the opening bracket "[" and after the closing bracket.



type
TMyArray = array [0..100] of Char;


When you look SysUtils.pas or in Delphi help then this is always written like this:


type
TMyArray = array[0..100] of Char;

PerIvar
08-12-2003, 12:12 PM
Just found this on the 1.1 point in the guide.


If you find cases where the source varies from these guidelines, then these guidelines, and not the errant source code, should be considered your standard. Nevertheless, you should use the source as a supplement to these guidelines, at least so far as it can help you get a general feel for how your code should look.


So you should follow the standard guide :)

marcov
22-02-2005, 07:46 AM
This is not a question but a suggestion:

When you write code that you intend to share with other people or if you work in a team, it's a good idea to follow the official Borland Object Pascal style guide. Most people have read the style guide and a lot of people code accordingly but I still see a lot of people capitalizing reserved words or using all caps, people who ident with single spaces or with tabs, etc. ...


The capitalisation of keywords is Pascal (and even Wirthian languages) in general. Borland trying to ban it is unnatural and counterproductive.

There are more defects, e.g. .dpr is used for GUI project (which is an auto generated file mostly) and console programs, capitalisation of filenames is nono on *nix (Kylix!)

For some important hints about cross compiler defines that are not covered in the styleguide see
http://www.stack.nl/~marcov/porting.pdf

LP
10-10-2005, 10:12 PM
The style also depends on organization and not necessary may comply with Borland's specification.

For instance, here in Afterwarp Interactive we try to have the code as compact as possible, while maintaining maximum readability. Here's an example:

type
// Yes, we ident with one space. :)
TMyArray = array[0..99] of Integer;

// 'string' is a reserved word and thus is not capitalized,
// unlike Delphi IDE which puts it as 'String'.
TStringArray = array of string;


It's difficult to say some code standard is good or bad, but at least *a standard* should be followed rather than using random style.

HopeDagger
27-11-2006, 01:17 AM
Nuts, this link seems to lead to a dead-end now. Anyone have a copy of what it used to point to?

savage
27-11-2006, 09:56 AM
Try this - http://bdn.borland.com/article/10280

Memphis
25-09-2008, 06:24 PM
before you say, yes i know this thread is couple year old, but new people will read it......

first time i have read this topic, and i thought i'd input something...

personally, i disagree with following the "official" Borland Object Pascal style.

rather then people get used to coding the way everyone else does, people should spend more time learning to adapt to other peoples code. its kind of like the saying 'take what you're given, or get nothing'

i code in many different languages, and in all i have a different style of coding, those styles help me write my code quicker, more comfortably, if i share that code, i will not rewrite it another way just for someone else, that would just be lazy on the 3rd parties end, they're getting it for nothing, what is the problem.....

if one of you get a job working for a game development company and they have a different style to you, "you" need to adapt to their style, not them adapt to your style...

anyways just my opinion....

-MM