I currently have a function that creates a stringbuilder variable using an object.
The issue that I am having is the function is now extremely long and I am beginning to realize that I can split it into multiple functions easily for readability and possibly maintainability. Would there be any reason not to split them into separate functions? Will there be a performance boost or the opposite?
Here is a smaller version of the current stringbuilder function I am using (because it is much larger around 300+ lines of code). As you can see I would be able to split into functions based on each line input:
private static StringBuilder GetObjectData(Object obj)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine(("TempClass;" +
obj.TempClass.TempValue +
obj.TempClass.TempValue1 +
obj.TempClass.TempValue2 +
obj.TempClass.TempValue3 +
obj.TempClass.TempValue4 +
obj.TempClass.TempValue5 +
obj.TempClass.TempValue6 +
obj.TempClass.TempValue7 +
obj.TempClass.TempValue8));
sb.AppendLine(("TempClass2; +
obj.TempClass2.TempValue));
sb.AppendLine(("TempClass3;" +
obj.TempClass3.TempValue));
if (obj.TempClass3.TempValue != null && obj.TempClass3.TempValue1 != null)
{
sb.AppendLine(("TempClass3;" +
obj.TempClass3.TempValue +
obj.TempClass3.TempValue1));
}
sb.AppendLine(("TempClass4;" +
obj.TempClass4.TempValue));
foreach (string element in obj.TempClass5.TempValue)
{
sb.AppendLine(("TempClass5;" + element));
}
return sb;
}
Any input is much appreciated!