I have an SOA app, and have started to run into some performance issues.
I have models coming OUT of REST that look similar to…
public class Person
{
public Guid Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public Address Address { get; set; }
public IEnumerable<Hobby> Hobbies { get; set; }
public IEnumerable<Interests> Interests { get; set; }
public IEnumerable<Friends> Friends { get; set; }
}
This turns into a pretty large model pretty quickly when it is being returned via REST with all of those fields populated.
So, my basic question is…Is it better to transfer large models such as above, and use FEWER Rest calls, or transfer smaller objects and use more Rest calls to retrieve the other pieces of data. I.E. have a model like this…
public class Person
{
public Guid Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public AddressId AddressId { get; set; }
public IEnumerable<Guid> Hobbies { get; set; }
public IEnumerable<Guid> Interests { get; set; }
public IEnumerable<Guid> Friends { get; set; }
}
And now go an grab the other properties as needed…
Thoughts?
Personally, I prefer a lighter object be returned. I could elaborate as to why, but this article does a pretty good job of doing it for me:
http://davybrion.com/blog/2010/05/why-you-shouldnt-expose-your-entities-through-your-services/
Now, in your case, you can return lists inside of your objects, and then have REST calls that will accept a list of IDs (in your case Guids) and then returns a list of objects, themselves being lightweight. This would give you the best of both worlds – lighter objects and a reduced number of REST calls.