Tuesday, 3 November 2015

General Code Review

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;
}

3 comments:

  1. 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.

    Building 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.

    ReplyDelete
  2. 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.

    ReplyDelete
  3. For 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

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...