views:

23

answers:

2

hi, i have a general design question.

we have a fairly big data model that represents an clinical object, the object itself has 200+ child attributes in the hierarchy.

and we have a SetObject operation, and a GetObject operation. my question is, best practice wise, would it make sense to use that single data model in both operations or different data model for each? Because the Get operation will return much more details than what's needed for Set.

an example of what i mean: the data model has say ProviderId, and ProviderName attributes, in the Get operation, both the ProviderId, and ProviderName would need to be returned. However, in the Set operation, only the ProviderId is needed, and ProviderName is ignored by the service since system has that information already. In this case, if the Get and Set operations use the same data model, the ProviderName is exposed even for Set operation, does that confuse the consuming developer?

+1  A: 

It would say: it depends :-)

No seriously. How do you edit / work on the object? I assume your software is calling the WCF service to retrieve an object, using an ID or a search term or something.

So you get back the object with 200+ attributes. How do you work on it, how much of it do you typically change?

If you typically only change a handful of attributes - then maybe having a generic SetProperty method on the service that would take the object ID, a property name, and a new value, might make sense. But think about how this is going to work:

  • the server side code will get the ID for the object
  • it will load the object from the database
  • it will then set a single property to a new value
  • it will save the object back to the database

What if you update four properties? You'd go through 4 of those cycles. Or: you could extend the SetProperty method to include a dictionary of (property name, value) pairs.

So I guess it depends on how many of those 200 properties are you changing at any given time? If you change 10%, 20% of those properties - wouldn't it be easier to just pass back the whole, modified object?

marc_s
A: 

This looks like a good candidate for using your clinical object as canonical model and providing a restful style service interface. You can then provide different views, or representations of your your data object with only the fields required based on the usage model. Your verbs (get, set) will become the http standard Get, Put.

There are a number of open source Rest frameworks that you can use to make this easier to get started. Restlet is one that I have used successfully.

MadPharoah