手机站
网通分站
电信主站
密 码:
用户名:
当前位置 : 主页>程序设计>delphi>列表

Object Pascal Style Guide

来源:互联网 作者:西部数码 时间:2008-04-09
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!
Object Pascal Style Guide - by Charles Calvert

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

Object Pascal Style Guide

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

We take it for granted that many well established shops will have conventions different than those specified here. As a result, we strongly recommend using a tool that can convert your code into Borland style before submitting it to Borland, Project JEDI, or any other public source repository. We don''''t want to force you to change your conventions, but we insist that all code that ships with Borland products follows these conventions. We strongly encourage you to follow these conventions when submitting code into any form of public repository.

Object Pascal is a beautifully designed language. One of its great virtues is its readability. These standards are designed to enhance that readability of Object Pascal code. When developers follow the simple conventions laid out in this guide, they will be promoting standards that benefit all Delphi developers by using a uniform style that is easy to read. Efforts to enforce these standards will increase the value of a developer''''s source code, particularly during maintenance and debugging cycles.

It goes without saying that these are conventions based primarily on matters of taste. Though we believe in, and admire the style promoted in these pages, we support them not necessarily because we believe they are right and others are wrong, but because we believe in the efficacy of having a standard which most developers follow. The human mind adapts to standards, and finds ways to quickly recognize familiar patterns, thereby assimilating meaning quickly and effortlessly. It is the desire to create a standard that will make reading code as simple as possible for the largest number of people that is behind this effort. If at first our guidelines seem strange to you, we ask you to try them for awhile, and then we are sure you will grow used to them over time. Or, if you prefer, keep your code in your own format, and run it through a program that follows our guidelines before submitting it to Borland or to a public repository.

Some text editors, such as Visual SlickEdit can help you format your code according to a particular style. Readers who are aware of other tools that provide this same service should write me at that address provided at the end of this section.

One free formatter developed by Egbert van Nes is available at the following URL:
http://www.slm.wau.nl/wkao/delforexp.html.

A commercial option is CrackerJax for Delphi:
http://www.kineticsoftware.com/html/products.html.

Before closing this introduction, I want to reiterate that on the Borland web site, and on the CDs that we ship with our product, these standards are the law. We want to present our code in a unified and easy to read style, and enforcing the rules in this guide is the simplest way to achieve that end.

Do not post this specification on other web sites. Instead, simply link to this version of the document.

We accept feedback in the form of corrections or suggestions. Send your communications to Charlie Calvert .


Contents

  • 1.0 Introduction
    • 1.1 Background
    • 1.2 Acknowledgments

  • 2.0 Source Files
    • 2.1 Source-File Naming
    • 2.2 Source-File Organization
      • 2.2.1 Copyright/ID block comment
      • 2.2.2 unit declaration
      • 2.2.3 uses declarations
      • 2.2.4 class/interface declarations

  • 3.0 Naming Conventions
    • 3.1 Unit Naming
    • 3.2 Class/Interface Naming
    • 3.3 Field Naming
    • 3.4 Method Naming
    • 3.5 Local Variable Naming
    • 3.6 Reserved Words
    • 3.7 Type Declarations

  • 4.0 White Space Usage
    • 4.1 Blank Lines
    • 4.2 Blank Spaces
      • 4.2.1 A single blank space (not tab) should be used:
      • 4.2.2 Blanks should not be used:
    • 4.3 Indentation
    • 4.4 Continuation Lines

  • 5.0 Comments
    • 5.1 Block Comments
    • 5.2 Single-Line Comments

  • 6.0 Classes
    • 6.1 Class Body Organization
    • 6.2 Method Declarations
    • 6.3 Data Store Declarations

  • 7.0 Interfaces
    • 7.1 Interface Body Organization

  • 8.0 Statements
    • 8.1 Simple Statements
      • 8.1.1 Assignment and expression statements
      • 8.1.2 Local variable declarations
      • 8.1.3 Array declarations

        文章整理:西部数码--专业提供域名注册虚拟主机服务
        http://www.west263.com
        以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!