Hi. I tend to sucessfully write compact applications that can encapsulate many business logic in a simple and non-redundant way. I tend to create small methods, but over time I arrive to methods that have too many parameters. I know every code requires its design, but I see and antipattern in my behaviour and I am not sure which would be the best way to fight against it.
A typical situation would be something like:
public loanStructure CalculateSomeComplicatedInterestRate(enum clientType,
int totalAmout, bool useTaxes, bool doYearlySummary, bool doNotReloadClient, etc)
{
loanStructure ret = new loanStructure();
if (doNotReloadClient) ... ;
...
if (doYearlySummary) GroupResults(ret);
return ret;
}
and inside the method, a tree of calls forwards the boolean settings (doYearlySummary, doNotReloadClient, etc) to different business rules that acts on the calculation.
I.E., the problem does not reside on the fact that all parameters could be encapsulated into an object (bigParameterStructure)... I am not comfortable with the masterMethod pattern, but making overloads such as CalculateSomeComplicatedInterestRateMonthly and CalculateSomeComplicatedInterestRateYearly would just hide a private CalculateSomeComplicatedInterestRate.... some problem!!
Of coarse object-orienting design would help... but I still endup having this kind of methos somewhere on my objects...
Well guys... any help is welcome.
Pablo.