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...
-
Recently I was working with search bar in search result page where I encounter below error: Sorry, Something went wrong An error occurred...
-
SharePoint Designer 2013 – a tool that is most useful few years back, still handy in some projects, and that still gives me trouble when nee...
No comments:
Post a Comment