1. Introduction
This document is specified for SWT’s developers who will attempt to a C# project development. The developers should read this specification for standardization coding style and understandable for other teammates. After all, it could make your project more standard and professional.
Note that, this document just specified with C# Language.
2. Coding Conventions
2.1. Terminology and Definition
Access Modifier C# keywords public, protected, internal, and private declare the allowed code-accessibility of types and their members. Although default access modifiers vary, classes and most other members use the default of private. Notable exceptions are interfaces and enumerate which both default to public.
Camel Case: A word with the first letter lowercase, and the first letter of each subsequent word-part capitalized. Example: customerNameAndThings
Pascal Case: A word with the first letter capitalized, and the first letter of each subsequent word-part capitalized. Example: CustomerNameAndThings
Always : It must be follow this specification as a law.
Avoid: It should be avoid use this specification. In worst, it could be use.
Never: Every exceptions of this case is not allowed.
Possible: It recommend follow this specification.
5 trang |
Chia sẻ: tienduy345 | Lượt xem: 1867 | Lượt tải: 0
Bạn đang xem nội dung tài liệu C# Coding convention, để tải tài liệu về máy bạn click vào nút DOWNLOAD ở trên
[PROJECTNAME]
C# Coding convention
Date
[May 18, 2010]
Version
[1.1]
Status
[Approved]
Author
[Nguyen Thi Thanh Thuy, CEO]
Reviewed by
[Le Tat Hai, Technical Director]
Approved by
[Nguyen Thi Thanh Thuy, CEO]
Revision History
Date
Version
Description
Author
07/8/2011
1.0
State out basically coding standard for C Sharp language
07/8/2011
1.0
Added naming of GUI controls in VS C# 2005
07/8/2011
1.0
Fixed Method style from camelCase to PascalCase
Table of Contents
Introduction
This document is specified for SWT’s developers who will attempt to a C# project development. The developers should read this specification for standardization coding style and understandable for other teammates. After all, it could make your project more standard and professional.
Note that, this document just specified with C# Language.
Coding Conventions
Terminology and Definition
Access Modifier C# keywords public, protected, internal, and private declare the allowed code-accessibility of types and their members. Although default access modifiers vary, classes and most other members use the default of private. Notable exceptions are interfaces and enumerate which both default to public.
Camel Case: A word with the first letter lowercase, and the first letter of each subsequent word-part capitalized. Example: customerNameAndThings
Pascal Case: A word with the first letter capitalized, and the first letter of each subsequent word-part capitalized. Example: CustomerNameAndThings
Always : It must be follow this specification as a law.
Avoid: It should be avoid use this specification. In worst, it could be use.
Never: Every exceptions of this case is not allowed.
Possible: It recommend follow this specification.
Naming Conventions
“c” camelCase
“P” PascalCase
“U” UPPERCASE
“_” Prefix with “_”
Field
Avoid using public field. (it’s not recommend of using public)
Pascal Case if public or prefix with “_” and Pascal Case if access modifier is protected, internal, private. Examples:
public string Name;
private int _Age;
Any GUI controls could be named with PascalCase but it’s must be prefix with GUI type (or abbreviate type). Example:
Control Name
Prefix
Example
Label
lb
lbLable
Button
bt
btButton
ListBox
ls
lsListBox
RadioButton (Option buttons)
op
opRadioButton
ComboBox
cb
cbComBox
MenuStrip
mnu
mnuMenuStrip
TextBox
tx
txTextBox
CheckBox
ck
ckCheckBox
CheckedListBox
ckl
cklCheckListBox
ListView
lv
lvListView
PictureBox
pb
pbPictureBox
TreeView
trv
trvTreeView
Panel
pn
pnPanel
GroupBox
gb
gbGroupBox
RichTextBox
rtx
rtxRichTextBox
Control Name
Prefix
Example
LinkLabel
lkl
lklLinkLabel
ProgressBar
pgb
pgbProgressBar
ToolTip
tt
ttToolTip
TabControl
tbc
tbcTapControl
ContextMenuStrip
cmnu
cmnuContextMenuStrip
StatusStrip
sts
stsStatusStrip
ImageList
imgl
imglImageList
Timer
tm
tmTimer