I have a C# client and a java server. I have data object that go on the wire back and forth. Lets call them FooData.cs where everything is just a get and a set (no logic)
FooData data = new FooData();
data.Price = 10;
data.Quantity = 20;
i have other derived fields that i want to use in the application but dont need to be sent on the wire so i have anothe class
FooWrapper.cs.
I inject the data object into the wrapper
FooWrapper wrapper = new FooWrapper(Foodata);
wrapper.Price = 10;
wrapper.Quantity = 20;
double total = wrapper.GetTotal();
and the wrapper has a lot of the same properties as the data object (and we just delegate down) or the wrapper also has a number of calculated properties. The only state the wrapper has is the data object (no other member variables)
We were having a debate about using this model versus using converters. The converter way would be to instead of having FooWrapper, have a FooBusinessObject and instead of injecting the "on the wire" object, we call a convert method that passes all of the data from the on the wire object to the business object.
FooData data = new FooData();
FooBusinessObject busObj = new FooBusinessObject();
busObj.Price = data.Price;
busObj.Quant= data.Quantity;
double total = busObj.GetTotal();
Any thoughts on what is better (wrapper versus business object / converter)