Code Review :- General
1. Remove the commented code
2. Variable name should not be contain "_".
3. Query should be in separate class.
4. Use Common log error when handle the exception
5. Use String.isNullorWhiteSpace instead of String.isNullorEmpty
6. Use Using Statement for variable scope should be limited.
7. Remove unnecessary if ... else ...
e.g. if (dtTasksAll != null && dtTasksAll.Rows.Count > 0)
{
gv.DataSource = dtTasksAll;
gv.DataBind();
}
else
{
gv.EmptyDataText = "No New Tasks found";
lblviewimg.Visible=false;
gv.DataSource = dtTasksAll;
gv.DataBind();
}
Optimized code :-
if(dtTasksAll == null)
{
gv.EmptyDataText = "No New Tasks found";
lblviewimg.Visible=false;
}
gv.DataSource = dtTasksAll;
gv.DataBind();
8. Terminate loop as soon as possible
e.g.
foreach (SPUser user in group.Users)
{
if (!string.IsNullOrEmpty(user.Email))
{
MailTo += MailTo == string.Empty ? user.Email : "," + user.Email;
}
}
Optimized code :-
foreach (SPUser user in group.Users)
{
if (string.IsNullOrWhiteSpace(user.Email)) Continue;
MailTo += MailTo == string.Empty ? user.Email : "," + user.Email;
}
Subscribe to:
Post Comments (Atom)
-
Recently I was working on sending mail using smtp server where I stuck on below error: IIS/SMTP - emails are stuck in mailroot/Queue ...
-
If you want to know which controlled fired post back at page load, here is some sample code. 1) for link button: string ctrlname = Page....
-
While working with SharePoint / JavaScript modal pop up you might encounter error "cannot read property 'showmodaldialog' of un...

No comments:
Post a comment