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)
The "Mark as Decorative" Feature in SharePoint: A Small Toggle With a Big Accessibility Impact
If you've spent any time building pages in SharePoint Online, you've probably noticed a new checkbox tucked inside the Accessibility...
-
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...
-
If you're managing SharePoint Online environments, there's a significant change on the horizon that you need to prepare for. Microso...
-
Issue : Recently, we had a requirement to sync the calendar between shared mailbox outlook and SharePoint Calendar list. We have created 2 f...
These are useful code review guidelines for improving code readability, maintainability, and performance. Practices such as removing commented-out code, separating database queries from business logic, handling exceptions consistently, and terminating loops early can make applications easier to maintain. Small, thoughtful refactoring decisions can also reduce duplication and simplify debugging.
ReplyDeleteBuilding a strong programming foundation helps developers understand why coding standards matter and how to apply them consistently in real-world projects. Python Coding Course can be relevant for learners who want to strengthen their programming fundamentals and develop cleaner coding habits.
Consistent practice is essential for translating coding principles into maintainable applications. Reviewing variable naming, exception handling, resource management, and control flow helps developers build more reliable software. Python Coding Training provides another resource for learners looking to improve their practical Python skills.
ReplyDeleteFor teams working with JavaScript, applying similar code review principles can improve readability and make collaborative development more efficient. Establishing shared coding conventions and reviewing code systematically helps maintain consistency across a project. Javascript Coding Training is relevant for organizations looking to strengthen their team's JavaScript development skills.
ReplyDelete