Студопедия
Случайная страница | ТОМ-1 | ТОМ-2 | ТОМ-3
АвтомобилиАстрономияБиологияГеографияДом и садДругие языкиДругоеИнформатика
ИсторияКультураЛитератураЛогикаМатематикаМедицинаМеталлургияМеханика
ОбразованиеОхрана трудаПедагогикаПолитикаПравоПсихологияРелигияРиторика
СоциологияСпортСтроительствоТехнологияТуризмФизикаФилософияФинансы
ХимияЧерчениеЭкологияЭкономикаЭлектроника

Naming Conventions and Standards

Читайте также:
  1. A Few Sub-genres, Conventions, and Examples
  2. Comment on the quotation of Richard C. Levin naming the main institutional priorities of The Yale University.
  3. How to follow the standards across the team
  4. I. Business Letter Format and Conventions
  5. Naming Kili and Fili, for instance), the exact situation at the moment may
  6. Politeness Conventions

 

Note: The terms Pascal Casing and Camel Casing are used throughout this document. Pascal Casing- First character of all words are Upper Case and other characters are lower case. Example: B ack C olor Camel Casing -First character of all words, except the first word are Upper Case and other characters are lower case. Example: b ack C olor

 

7.1. Use Pascal casing for Class names

 

public class С HelloWorld

{

...

}

 

 

7.2. Use Pascal casing for Method names

 

void SayHello (string name)

{

...

}

 

 

7.3. Use Camel casing for variables and method parameters

 

int totalCount = 0;

void SayHello(string name)

{

string fullMessage = "Hello " + name;

...

}

 

7.4. Use the prefix “I” with Camel Casing for interfaces (example: IEntity). Use the prefix “C” with Camel Casing for classes (example: CHelloClass)

Исключение из этого правила: класс Engine

 

7.5. Use Hungarian notation to name variables. All variables should use camel casing.

 

Table 7.1.

Type Prefix
bool is
byte byt
sbyte sbt
char chr
short sht
ushort ush
int int
uint uit
long lng
ulong ulg
float flo
double dbl
decimal dcm
object obj
string str
enum en
Date dat
Array arr

 

Example: local variable - strName

class member variable - mvStrName / mvObject / private ColCountries mvCountries - Type by self defined collections not using

module variable - modStrName

object variable - objName

 

 

7.6. Use Meaningful, descriptive words to name variables. Do not use abbreviations.

 

Good:

 

string strAddress

int intSalary

 

Not Good:

 

string nam

string addr

int sal

 

 

7.7. Do not use single character variable names like i, n, s etc. Use names like index, temp

 

One exception in this case would be variables used for iterations in loops:

 

for (int i = 0; i < count; i++)

{

...

}

 

If the variable is used only as a counter for iteration and is not used anywhere else in the loop, many people still like to use a single char variable (i) instead of inventing a different suitable name.

 

Note: you can to use the rule - to designate objective variables at viewing collections in in cycle for each with the prefix х.(example xObject.)

 

7.8. Do not use underscores (_) for local variable names.

 

7.9. All member variables must be prefixed with mv (member variant) so that they can be identified from other local variables.

 

 

7.10. Do not use variable names that resemble (ключевых, зарезервированных) keywords.

 

 

7.11. Prefix boolean variables, properties and methods with “is” or similar prefixes.

 

private bool isFinished

 

private bool mvIsFinished // for member variant

 

 

7.12. Namespace names should follow the standard pattern

 

<company name>.<product name>.<top level module>.<bottom level module>

 

Example: LizenzaDevelopment.ADAICA.adADR

 

7.13. Use appropriate prefix for the UI elements so that you can identify them from the rest of the variables.

 

 

Use appropriate prefix for each of the ui element. A brief list is given below. Since.NET has given several

controls, you may have to arrive at a complete list of standard prefixes for each of the controls (including third

arty controls) you are using.

 

Table 7.2

Control Prefix
Label lbl
TextBox txt
DataGrid dtg
Button btn
ImageButton imb
Hyperlink hlk
DropDownList ddl
ListBox lst
DataList dtl
Repeater rep
Checkbox chk
CheckBoxList cbl
RadioButton rdo
RadioButtonList rbl
Image img
Panel pnl
PlaceHolder phd
Table tbl
Validators val
ListView lvw
TreeView tvw
Menu mnu

 

7.14. File name should match with class name.

 

For example, for the class HelloWorld, the file name should be HelloWorld.cs

 

 

7.15. Use Pascal Case for file names.

 

7.16. To use the table 7.3 for last element codes (priority behind the set forth above rules).

Table 7.3.

      must be example
Application     ADAICA == Advanced Documents, Assets & Information Control Application  
DB-User     ASOADAC == Advanced Service Orientated Architecture (SOA) Data Access Components (DAC)  
DB-Objects – it was prefix AS, better should AD, because AS is a reserved word, we take also the prefix AD_
  PL/SQL-Routine (Package, stored procedure)   prefix AD_ AD_OBJECT
  Package procedure/function   prefix object name (can be short) AD_OBJECT.OBJECT_INSERT
  View   prefix AV_ and may be any group prefix Example AV_EL_---- AV_OBJECT, AV_EL_SWITCH
  Data table   thematic prefix (3 chars)  
  exemples for thematic prefixes SICAD-Tables A_-alpha data, UT_ - table for all object, E_ - power, G - gas, W - water A_ADDRESS, UT_OBJECT, E_PART, G_ARMATURE, W_TANK
    our tables VUO_-objects, VUD_-documents, VUM_-maintenance, VUB_-basic, VUS_-services VUO_MAST, VUD_DOCUMENT, VUB_CLASS_TYPE, VUS_EXC_SEND
  Configuration Table   prefix CONF_thematic prefix CONF_VUB_MASK_LABEL
Oracle programm code
  variable      
    global prefix gl_ gl_name
    module prefix mod_ mod_name
    local prefix v_ v_name
  constant      
    global prefix GC_, to shift GC_NAME
    module prefix MC_, to_shift MC_NAME
    local prefix C_, to shift C_NAME
  parameter      
    input Prefix in name
    output prefix out out_name
    input/output prefix uni uni_name
Namespace     prefix ad adObject
Project        
  Project User Control (Control library)   prefix ctr, camel Case ctrObject.ctl
  Project DLL(Class library)-Assembly   prefix AD, to shift, 5 max 9 letters ADOBJ.dll
  Project EXE(Windows application)   prefix AD, Ungarn Case ADObject.exe
         
.NET-Objects        
  User defined      
    User Control prefix ad, camel Case adObject
    Class Prefix C, Ungarn Case CObject
    Collection prefix col, singular, camel Case colObject
    Form prefix win, camel Case winObject
    Module prefix mod, camel Case modObject
         
  .NET defined      
    Tab prefix tab, camel Case tabObject
    Picturebox prefix pbx, camel Case pbxObject
    Combobox prefix cmb, camel Case cmbObject
    Another Controls (for example split container) prefix ada, camel Case adaObject
         
.NET Programm code        
  Procedure/Function      
  Prefixes for names of variables   str, int, lng, dbl, bln, all user defined classes must with prefix obj (Obj)
  Variable      
    global prefix glDatatype (initcap) glStrName / glObjName
    module prefix modDatatype (initcap) modStrName / modObjName
    local prefix datatype strName / objName
  Parameter      
    input prefix Datatype, Camel case strName / objName
    output prefix outDatatype outStrName / outObjName
    Input / output prefix uniDatatype uniStrName / uniObjName
  Constant      
    global prefix cGlDatatype, Name to shift cGlStrNAME
    module prefix cModDatatype, to_shift cModStrNAME
    local prefix cDatatype, to shift cStrNAME
         
  Enum   prefix en enName
  Event   prefix Ev EvReadyBySave

 

 


Дата добавления: 2015-10-31; просмотров: 95 | Нарушение авторских прав


<== предыдущая страница | следующая страница ==>
How to follow the standards across the team| FEAR AND COWARDICE

mybiblioteka.su - 2015-2024 год. (0.009 сек.)