J
Jeff Gilbert
Hello, I would appreciate some input to the following question of "proper"
design (if such a thing exists).
I'm implementing a reporting subsystem for the project I'm currently working
on. I handle the display of the reports via a DeliveryEngine object that is
implemented like so:
IDeliveryEngine (interface)
|
|
DeliveryEngineBase (mustinherit)
|
|
PreviewEngine (final implementation)
I have a property set up called Target. It defines the place where the
reports are to be delivered. For the PreviewEngine it is the form that
contains the viewer control. For the PrintEngine, it is the printer's name.
In the interface it is declared as type "Object". However, each
implementation can take a different type of Target for obvious reasons. To
maintain type safety I want to shadow the Target property and re-declare its
type to the specific type each implementation needs.
For example, whereas the interface's Target property is of type "Object", I
would like to declare the PreviewEngine's Target property as type "Form":
Shadows Property Target as Form
The problem obviously is that this will break the original interface
contract, but its the only way to maintain type safety for my
implementations...and I feel this is a situation where it makes sense to
break the contract - each implementation is different. However, I need to be
able to handle each of the implementations as the same type of object. Can
anyone give me some advice? Thanks!
Jeff Gilbert
design (if such a thing exists).
I'm implementing a reporting subsystem for the project I'm currently working
on. I handle the display of the reports via a DeliveryEngine object that is
implemented like so:
IDeliveryEngine (interface)
|
|
DeliveryEngineBase (mustinherit)
|
|
PreviewEngine (final implementation)
I have a property set up called Target. It defines the place where the
reports are to be delivered. For the PreviewEngine it is the form that
contains the viewer control. For the PrintEngine, it is the printer's name.
In the interface it is declared as type "Object". However, each
implementation can take a different type of Target for obvious reasons. To
maintain type safety I want to shadow the Target property and re-declare its
type to the specific type each implementation needs.
For example, whereas the interface's Target property is of type "Object", I
would like to declare the PreviewEngine's Target property as type "Form":
Shadows Property Target as Form
The problem obviously is that this will break the original interface
contract, but its the only way to maintain type safety for my
implementations...and I feel this is a situation where it makes sense to
break the contract - each implementation is different. However, I need to be
able to handle each of the implementations as the same type of object. Can
anyone give me some advice? Thanks!
Jeff Gilbert