我有一個對象稱爲參數,從方法降低到方法,並通過包邊界調用樹。它有大約五十個狀態變量。每種方法可能使用一個或兩個變量來控制其輸出。上帝的對象 - 減少耦合到'主'對象
我認爲這是一個糟糕的主意,因爲我無法輕易地看到一個方法需要什麼功能,甚至如果對於與我當前模塊完全無關的模塊Y的某些參數組合,可能會發生什麼情況。
什麼是減少耦合到這個神物體,或理想地消除它的一些好技術?
public void ExporterExcelParFonds(ParametresExecution parametres)
{
ApplicationExcel appExcel = null;
LogTool.Instance.ExceptionSoulevee = false;
bool inclureReferences = parametres.inclureReferences;
bool inclureBornes = parametres.inclureBornes;
DateTime dateDebut = parametres.date;
DateTime dateFin = parametres.dateFin;
try
{
LogTool.Instance.AfficherMessage(Variables.msg_GenerationRapportPortefeuilleReference);
bool fichiersPreparesAvecSucces = PreparerFichiers(parametres, Sections.exportExcelParFonds);
if (!fichiersPreparesAvecSucces)
{
parametres.afficherRapportApresGeneration = false;
LogTool.Instance.ExceptionSoulevee = true;
}
else
{
呼叫者會做:
PortefeuillesReference pr = new PortefeuillesReference();
pr.ExporterExcelParFonds(parametres);
「參數」是一個配置對象嗎? – 2009-10-16 20:25:56
是的。用於讓UI帶有業務層可能需要的任何參數。 – 2009-10-16 20:28:41