Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Style guide

  1. #1

    Style guide

    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...5,10280,00.htm
    Ask me about the xcess game development kit

  2. #2

    Style guide

    Yes sir! :salute:
    [size=10px][ Join us in #pgd on irc.freenode.net ] [ Sign the Petition for a Software Patent Free Europe ][/size]

  3. #3

    Style guide

    Good call -- I've been meaning to bring this up but keep forgetting.

    I've made this thread a sticky.
    "All paid jobs absorb and degrade the mind."
    <br />-- Aristotle

  4. #4

    Style guide

    There's also a delphi-jedi project which does the formatting for you.
    http://jedicodeformat.sourceforge.net/
    wolfnight.org - Wolfnight Game Development

  5. #5

    Style guide

    8.1.3 Array declarations
    There should always be a space before the opening bracket "[" and after the closing bracket.

    Code:
    type
      TMyArray = array &#91;0..100&#93; of Char;
    When you look SysUtils.pas or in Delphi help then this is always written like this:
    Code:
    type
      TMyArray = array&#91;0..100&#93; of Char;

  6. #6

    Style guide

    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
    Regards
    <br />Per Ivar T.

  7. #7

    Re: Style guide

    Quote Originally Posted by Harry Hunt
    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

  8. #8

    Style guide

    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:
    Code:
    type
     // Yes, we ident with one space. &#58;&#41;
     TMyArray = array&#91;0..99&#93; 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.

  9. #9

    Style guide

    Nuts, this link seems to lead to a dead-end now. Anyone have a copy of what it used to point to?
    Game-Dev Journal: http://skirmish.dreamhosters.com/devlog/

  10. #10

    Style guide

    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •