我目前正在处理一组报告,这些报告包含许多不同的部分(均需要不同的格式),并且我正在尝试找出构造代码的最佳方法。我们过去完成的类似报告最终都具有非常大的功能(超过200行),这些功能可以对报告进行所有数据处理和格式化,从而使工作流看起来像这样:
DataTable reportTable = new DataTable();
void RunReport()
{
    reportTable = DataClass.getReportData();
    largeReportProcessingFunction();
    outputReportToUser();
}
我希望能够将这些大功能分解为较小的块,但恐怕最终我将拥有数十个不可重用的功能,而类似的“在这里做所有事情”功能的唯一作用是调用所有这些较小的函数,如下所示:
void largeReportProcessingFunction()
{
    processSection1HeaderData();
    calculateSection1HeaderAverages();
    formatSection1HeaderDisplay();
    processSection1SummaryTableData();
    calculateSection1SummaryTableTotalRow();
    formatSection1SummaryTableDisplay();
    processSection1FooterData();
    getSection1FooterSummaryTotals();
    formatSection1FooterDisplay();
    processSection2HeaderData();
    calculateSection1HeaderAverages();
    formatSection1HeaderDisplay();
    calculateSection1HeaderAverages();
    ...
}
或者,如果我们更进一步:
void largeReportProcessingFunction()
{
    callAllSection1Functions();
    callAllSection2Functions();
    callAllSection3Functions();
    ...        
}
这真的是更好的解决方案吗?从组织的角度来看,我认为是这样(即,一切都比可能的组织得要好得多),但是就代码的可读性而言,我不确定(可能只调用其他函数的功能链很大)。
有什么想法吗?