Coding Techniques:
- Inline Coding
- Code Behind
1.Inline Coding:
It contains both Designer Code & Business Logic in .aspx page.
2. Code Behind:
• Designer Code in .aspx page
• Business Logic in .aspx.cs page
What is Designer Code?
It is required for designing the UI.
What is Business Logic?
It is required for executing the logic behind the screen.
Coding Standards of C# Asp.Net:
· Pascal Casing: - First
character of all words are Upper Case and other characters are lower case.(class
names, method names)
Ex: BackColor
·
Camel Casing: - First
character of all words, except the first word are Upper Case and
other characters are lower case.(variable names & method parameters)
Ex: backColor
·
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++ )
{
...
}
{
...
}
·
Do not use
underscores (_) for local variable names.
·
Namespace names
should follow the standard pattern
<company
name>.<product name>.<top level module>.<bottom level
module>
·
Use
appropriate prefix for the UI elements so that you can identify them from the
rest of the variables.
a. Use a common prefix ( ui_ ) for all UI elements.
This will help you group all of the UI elements together and easy to access all
of them from the intellisense.
b. 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 party controls) you are using.
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
|
·
File name should
match with class name.
For example, for the class
HelloWorld, the file name should be helloworld.cs (or, helloworld.vb)
·
Use Pascal Case
for file names.
No comments:
Post a Comment