You are on page 1of 4

COMMON DEFECTS & SOLUTION

Title

Error Location

1 Check Null value of a string

Class Abc, Line 81

2 Use too many unnecessary


methods/functions

Class Abc, Line 82

Description

if(str == null) may be not exactly

Type

Severity

Coding Convention Cosmetic

Break a complex method/function to more simple


Coding logic
methods/functions is a good approach. However, if
the simple method/function is only one or two lines
of code, and could not be re-use then you needn't to
break

Cosmetic

Cause

Inexperienced Developer
-Developers lack of experience

Suggested preventive action or Solution

Should use if(str.length <= 0)


For example:
Instead of break the SaveToFile to more simple functions (included Save function)
public bool SaveToFile(XmlDocument write, string fileName)
{
//Valid data here and assign value before save
//................
//Save to file
Save(write, fileName);
}
private void Save(XmlDocument writer, string fileName)
{
writer.Save(fileName);
}
You can call Save method directly from SaveToFile function:
public bool SaveToFile(XmlDocument write, string fileName)
{
//Valid data here and assign value before save
//................
writer.Save(fileName);
}

You might also like