T
tmonico
Hi all,
I have a general OO question that I'd like to pose. Here's the
scenario.
Three classes, one business object class and two worker classes. The
worker classes need data from the business object class. In your
opinion is it better to have the worker classes take the business
object as a parameter and access the business objects data through the
business object public interface or is it better to completely decouple
the business object from the worker calsses and pass in discrete
parameters to the worker object methods?
For example:
WokerObject.DoSomethig(BusinessObject)
{
Do someThing with BusinessObject.PropertyA
Do someThing with BusinessObject.PropertyB
Do someThing with BusinessObject.PropertyC
}
or
WokerObject.DoSomethig(BusinessObject.PropertyA,
BusinessObject.PropertyB, BusinessObject.PropertyC)
{
Do someThing with PropertyA
Do someThing with PropertyB
Do someThing with PropertyC
}
The first method is cleaner in my opinion. It has a simplified
interface, however WorkerObject is now coupled to BusninessObject. In
the second method the interface is busier and not as clean, but
WorkerObject and BusinessObject are not coupled.
So what are the Pros and Cons of each approach? Which do you think is
better and why? I originally stated that there were two WorkerClasses.
I did this because I'd like to know if having many WorkerObjects
classes that use BusinessObject would affect your opinion.
I look forward to your insight.
I have a general OO question that I'd like to pose. Here's the
scenario.
Three classes, one business object class and two worker classes. The
worker classes need data from the business object class. In your
opinion is it better to have the worker classes take the business
object as a parameter and access the business objects data through the
business object public interface or is it better to completely decouple
the business object from the worker calsses and pass in discrete
parameters to the worker object methods?
For example:
WokerObject.DoSomethig(BusinessObject)
{
Do someThing with BusinessObject.PropertyA
Do someThing with BusinessObject.PropertyB
Do someThing with BusinessObject.PropertyC
}
or
WokerObject.DoSomethig(BusinessObject.PropertyA,
BusinessObject.PropertyB, BusinessObject.PropertyC)
{
Do someThing with PropertyA
Do someThing with PropertyB
Do someThing with PropertyC
}
The first method is cleaner in my opinion. It has a simplified
interface, however WorkerObject is now coupled to BusninessObject. In
the second method the interface is busier and not as clean, but
WorkerObject and BusinessObject are not coupled.
So what are the Pros and Cons of each approach? Which do you think is
better and why? I originally stated that there were two WorkerClasses.
I did this because I'd like to know if having many WorkerObjects
classes that use BusinessObject would affect your opinion.
I look forward to your insight.