Assume I have a class called Customer
. Now I need to render the customer on view. So I created CustomerViewModel
to use in binding. I am looking for the best way to create the CustomerViewModel
class. Following are my thoughts on creating it.
1 - Create all the properties in the customer again on the view model. Inject the customer instance into view model and each properties will retrun the value from this customer object. Advantage of this method is that I can create a common base class for all view models and have common functionality dumped there. Disadvantage will be the time required to create all the properties again on the view model and doing the maintenance.
2 - Derive the view model from customer. So I have all the propeties of customer in view model. But this will not allow me to use a common base class and put common view model logic there.
So I am wondering what will be the best method to create a view model? Is there any alternative methods that are better than what I thought?