Vous êtes sur la page 1sur 7

Document: Programming standards C# and

Project:
Programming standards

Project: Programming Standards


Client: nDeveloper operations - .Net department
Document: StandarsC#_VB_Net.doc

Created by:

Eduardo Barba Diego Pardo

Date:

January, 2011

Approved by:

Gerardo Morn

Date:

March, 2011

Modify by:

Eduardo Barba Diego Pardo

Date:

February, 2013

Approved by:

Gerardo Morn

Date:

April, 2013

Version:

V3

Date:

April, 2013

Created by nDeveloper Ca. Ltda.


January, 2011

Confidential - nDeveloper Ca. Ltda.

Visual Basic .Net

Document: Programming standards C# and


Project:
Programming standards

Visual Basic .Net

INDEX
1.Introduction.............................................................................................................................. 3
2.Definition.................................................................................................................................. 3
3.Capitalization styles.................................................................................................................. 3
Pascal case............................................................................................................................... 3
Camel case............................................................................................................................... 3
Uppercase................................................................................................................................ 3
4.Programming standards definition............................................................................................ 4
5.Ndeveloper Standards.............................................................................................................. 7
Namespace............................................................................................................................... 7
Reference.................................................................................................................................... 7

Confidential - nDeveloper Ca. Ltda.

Document: Programming standards C# and


Project:
Programming standards

Visual Basic .Net

1. INTRODUCTION
The purpose of this document is to describe the programming standards to be used for
developing applications using the programming languages C # and Visual Basic. Net
accordance with good development practices and conventions in force in the industry.

2. DEFINITION
These conventions are industry accepted to develop C # and VB.NET software. While different
naming conventions in organizations may vary, the list below is becoming the de facto
standard in the industry. Please consider the absence of Hungarian notation. These naming
rules are suggested to be applied in all developments .NET, including ASP.NET web
applications, WPF, Silverlight and Windows Forms applications.
All the standards listed below are considered among the best programming practices, because
this convention is consistent with the standards of the Framework. Net and is easy to read.

3. CAPITALIZATION STYLES
PASCAL

CASE

The first letter of identifier and the first letter of the words concatenated must be uppercase.
The capitalization style PASCAL can be used in identifiers of three or more characters.
For example: BackColor

CAMEL

CASE

The first letter of an identifier is lowercase and the first letter of each subsequent concatenated
word is capitalized.
For example: backColor

UPPERCASE
All letters in the identifier are capitalized. Applicable only for identifiers that are formed by two
or fewer letters.
For example: System.IO, System.Web.UI

Confidential - nDeveloper Ca. Ltda.

Document: Programming standards C# and


Project:
Programming standards

Visual Basic .Net

4. PROGRAMMING STANDARDS DEFINITION


Standard Based Upon Microsoft .NET Library Standards
TYPE

STANDARD- CONVENTION

EXAMPLE

Namespaces

Pascal Case, no underscores.


Use
CompanyName.TechnologyNa
me as root. If you don't have a
company, use your domain
name or your own initials. Note
that any acronyms of three or
more letters should be pascal
case (Xml instead of XML)
instead of all caps.
Why: This convention is
consistent with the .NET
Framework and is easy to read.

AppliedIS.TimeCard.BusinessRules
IrritatedVowel.Controllers
PeteBrown.DotNetTraining.InheritanceDemo
PeteBrown.DotNetTraining.Xml
PeteBrown.DotNetTraining.InheritanceDemo
PeteBrown.DotNetTraining.Xml

Assemblies

Classes /
Structs

If the assembly contains a


single name space, or has an
entire self-contained root
namespace, name the
assembly the same name as
the namespace.
Why: This convention is
consistent with the .NET
Framework and is easy to read. AppliedIS.TimeCard.BusinessRules.dll
More importantly, however, it
IrritatedVowel.Controllers.dll
keeps your assembly names
and namespaces lined up,
making it really easy to figure
out what is any particular
assembly, and what assembly
you need to reference for any
given class.

Pascal Case, no underscores or


leading "C" or "cls". Classes
may begin with an "I" only if
the letter following the I is not
capitalized, otherwise it looks
like an Interface. Classes
should not have the same
name as the namespace in
which they reside. Any
acronyms of three or more
letters should be pascal case,
not all caps. Try to avoid
abbreviations, and try to
always use nouns.

Confidential - nDeveloper Ca. Ltda.

Widget
InstanceManager
XmlDocument
MainForm
DocumentForm
HeaderControl
CustomerListDataSet (typed dataset)

Document: Programming standards C# and


Project:
Programming standards

Visual Basic .Net

Collection
Classes

Follow class naming


conventions, but add
Collection to the end of the
name

Delegate
Classes

Follow
class
naming
conventions, but add Delegate WidgetCallbackDelegate
to the end of the name

Exception
Classes

Follow
class
naming
conventions,
but
add InvalidTransactionException
Exception to the end of the
name

Attribute
Classes

Follow
class
naming
conventions, but add Attribute WebServiceAttribute
to the end of the name

Interfaces

Follow
class
naming
conventions, but start the
name with "I" and capitalize
the letter following the "I"iar el
nombre con la letra "I".
It also distinguishes classes
from interfaces, where (unlike IWidget
in VB6) are truly different
beings.
This
avoid
name
collisions as well, as it is quite
common to have IFoo and a
class
named
Foo
that
implements IFoo.

Enumerations

Follow
class
naming
conventions. Do not add
"Enum" to the end of the SearchOptions (bitwise flags)
enumeration name. If the AcceptRejectRule (normal enum)
enumeration represents a set
of bitwise flags, end the name
with a plural.

Functions /
Subs

Pascal Case, no underscores


except in the event handlers.
Try to avoid abbreviations.
Many programmers have a
nasty habit of overly
abbreviating everything. This
should be discouraged. We're
not designing license plates or
being charged by the letter :)
Functions and subs must differ
by more than case to be
usable from case-insensitive
languages like Visual Basic
.NET

Confidential - nDeveloper Ca. Ltda.

WidgetCollection

VB: Public Sub DoSomething(...)


C#: public void DoSomething(...)

Document: Programming standards C# and


Project:
Programming standards

Properties
Public/Membe
r Variables

Visual Basic .Net

Pascal Case, no underscores.


Try to avoid abbreviations.
Members must differ by more VB: Public Property RecordId As Integer
than case to be usable from C#: public int RecordId
case-insensitive languages like
Visual Basic .NET.

Parameters

Camel Case. Try to avoid


abbreviations.
Parameters
VB: ByRef recordId As Integer
must differ by more than case
to be usable from case- C#: ref int recorded
insensitive
languages
like
Visual Basic .NET.

ProcedureLevel
Variables

Camel Case
VB: Dim recordId As Integer
It also avoids naming collisions
with class-level variables (see C#: int recordId ;
below)

Class-Level
Variables

Camel Case with Leading


Underscore. In VB.NET, always
indicate
"Protected"
or
"Private", do not use "Dim".
Use of "m_" is discouraged, as
is use of a variable name that
differs from the property by
only case, especially with VB: Private _recordId As Integer
protected variables as that C#: private int _recordId ;
violates compliance, and will
make your life a pain if you
program in VB.NET, as you
would have to name your
members something different
from
the
accessor/mutator
properties.

Controls
Forms

Constants

Camel Case.
The first three consonants
correspond to the control
name followed by the name
on that identifies it.
If there is not a defined
nomenclature for a particular
control, their statement should
be agreed in the working
group.

Same naming conventions as _privateClassScopedConstant


public/private
member
variables
or
procedure localConstant
variables of the same scope. If
exposed publicly from a class, SomeClass.SomePublicConstant
use PascalCase.

Confidential - nDeveloper Ca. Ltda.

btnAceptar (Button)
txtUsuario (TextBox)
lblNombre (Label)
sqaConexion (SQL Adapter)

Document: Programming standards C# and


Project:
Programming standards

Visual Basic .Net

5. NDEVELOPER STANDARDS
NAMESPACE.
These are the standards agreed with nDeveloper development team for namespaces /
assemblies of the projects naming in a solution. Besides structuring solutions under logical
folders.
LAYER
Data Access
Business Logic
User interface
Test
Windows
Comunication
Foundation
Data Contract del WCF

NAME
DA
BL
UI
Test
WCF

ASSEMBLY
<NombreSolucion>.DA
<NombreSolucion>.BL
<NombreSolucion>.UI
<NombreSolucion>.Test
<NombreSolucion>.WCF

WCF.Data

Web services
Windows services
Comun (cross layers)

WEBS
WINS
Comun

<NombreSolucion>.WCF.Dat
a
<NombreSolucion>.WEBS
<NombreSolucion>.WINS
<NombreSolucion>.Comun

REFERENCE
-

.Net Naming Coventions and Programming Standards


http://10rem.net/articles/net-naming-conventions-and-programming-standards---bestpractices

C# Programming Guide
http://msdn.microsoft.com/en-us/library/vstudio/67ef8sbd%28v=vs.100%29.aspx

Confidential - nDeveloper Ca. Ltda.

Vous aimerez peut-être aussi