我有一个对象称为参数,从方法降低到方法,并通过包边界调用树。它有大约五十个状态变量。每种方法可能使用一个或两个变量来控制其输出。上帝的对象 - 减少耦合到'主'对象
我认为这是一个糟糕的主意,因为我无法轻易地看到一个方法需要什么功能,甚至如果对于与我当前模块完全无关的模块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