How to convert from Parent to Child?

I have a class in my domain model called

JobPlan

      

this class is stored / retrieved via ORM and used in various places.

I am creating a view that shows the twillist of this class and the treelist needs this class to implement a specific interface (the interface comes from a third party lib). However, adding an interface to the JobPlan class causes all assemblies that use that class to also reference the third-party control. It's not perfect.

I am thinking about availability

JobPlanPresenter

      

which just inherits JobPlan and implements methods for the interface. This would lead me to the question of how to then convert the JobPlan (parent) to a child JobPlanPresenter. I could create a transformer class that would just copy all fields from the parent class to the child class, but this seems like a pretty ugly hack to me, which will also kill all updates to the original objects, etc.

Do you think there is another way? Am I missing something completely?

0


source to share


1 answer


One solution would be to simply have the JobPlanPresenter link to the JobPlan. Then the JobPlanPresenter is just a wrapper around the JobPlan with a link to the JobPlan and JobPlan childrenPlanPresenter work fields.



+1


source







All Articles