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)
SharePoint Server 2016 and 2019 Retirement: What IT Professionals Need to Know
Microsoft SharePoint Server 2016 and 2019 are reaching end of support on July 14, 2026. With the April 2026 feature retirement deadline now ...
-
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...
-
Code Review :- General 1. Remove the commented code 2. Variable name should not be contain "_". 3. Query should be in separat...
-
Issue : Recently, we had a requirement to sync the calendar between shared mailbox outlook and SharePoint Calendar list. We have created 2 f...
No comments:
Post a Comment