views:

59

answers:

1

Hi,

I like the approach of having property bag objects (DTOs) which define the interface to my server, but I don't like writing code like this:

void ModifyDataSomeWay(WibbleDTO wibbleDTO)
{
    WibbleBOWithMethods wibbleBO = new WibbleBOWithMethods();
    wibbleBO.Val1 = wibbleDTO.Val1;
    wibbleBO.Val2 = wibbleDTO.Val2;
}

This copying code is quite laborious to write. If the copying code is unavoidable, then where do you put it? In the BO? In a factory? If it is possible to manually avoid writing the boiler plate code then how?

Thanks in advance.

+3  A: 

That looks like a job for AutoMapper, or (simpler) just add some interfaces.

Marc Gravell
Thanks - could you expand on how to use interfaces in this situation?
ng5000