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)
-
In last blog we learn how can we enable footer on SharePoint Online Modern Communication site. If you have not gone through that you can use...
-
One of our client wanted to show Employee Directory and our first suggestion was to build custom SPFx which will fetch data from Azure AD or...
-
Recently I was working on sending mail using smtp server where I stuck on below error: IIS/SMTP - emails are stuck in mailroot/Queue ...
No comments:
Post a Comment