I am working on a Xamarin application (Mvvm using Prism), I am also leveraging OData for communication between my backend and the mobile application.
The structure of my Mobile app is as follows:
- View
- View Model
- Service Layer
- OData Proxy to return Models
It is a little funky with OData because my domain/DTO models are the same and I end up exposing those directly to the View layer however I am the only developer and anymore abstraction would be cumbersome to maintain... At least that was my thought up until this point. I am now faced with a situation where I must perform additional logic on my Model object before the presentation layer:
The example of the model (MyComplexModel
) from OData looks something like this:
public class MyComplexModel
{
public int Id { get; set; }
public string Name { get; set; }
public List<MyComplexModelFeedback> Feedback { get; set; }
}
public class MyComplexModelFeedback
{
public int Id { get; set;}
public int PersonId { get; set; }
public int Vote { get; set; }
}
Usually I would just Bind
the view directly to MyComplexModel
and present it via a ListView
but now I want to flatten it/sum the Vote
property before I present. Is it appropriate to map this object to a new object directly in my ViewModel?
Or another thought I had was to add a facade pattern for my view models to use/expose, that I would map to in the service layer, however my code base would increase by >30%... Is there a simple way around this or is this problem a symptom of a larger design issue?