Reputation: 13
I am creating a method, implemented into a manager (like ReqManager) that is going to be called from a controller ReqController,
the definition could be:
public void LockTransDetail(IRow detailRow, DataSet data, string fieldName, bool lockYN)
public void LockTransDetail(IRow detailRow, IDecorator decorator, string fieldName, bool lockYN)
so I could perform the first and whe is implemented,
public void LockTransDetail(IRow detailRow, DataSet data, string fieldName, bool lockYN)
{
IDecorator decorator = GetDecorator(data);
......
}
Or the second option is, into the controller do:
IDecorator decorator = GetDecorator(data);
and then call to the method,
ReqControllerInstance.LockTransDetail(detailRow, decorator, fieldName, lockYN)
So what is better to pass as parameter the DataSet or de decorator into the created method ?
Upvotes: 0
Views: 76
Reputation: 14700
I'm not entirely sure I understood your question, but if I did, you're asking whether it's better for the Controller to call one monolithic method on the manager (Manager.DoSomething
), or whether to break it down into several steps (Manager.ConvertData
, Manager.GetDecorator
, and then Manager.DoSomethingWithDecorator
).
This would depend on what these steps are. In the example you bring, I would probably choose the first option. The Controller's role is to orchestrate the workflow - it knows that the current operation needs to be transferred into the RequestManager
's responsibility. What it shouldn't do is do the RequestManager
's work for it. If you use DataSets are your standard Data Transfer Objects, then that's what you should pass to the Manager. Any further processing should be done in the Manager.
Upvotes: 0
Reputation: 1659
The second option seems more generic and testable: you class implementation will be decoupled from concrete data
representation, meaning that you will be able to easily replace DataSet
with anything else and won't have to change LockTransDetail()
contract, as it depends on IDecorator
only.
Upvotes: 0