views:

42

answers:

2

I am creating a new web service for an application and am currently designing the web methods for each service. I have noticed that there is no real different in my case between create and save except that save requires an ID and create does not.

The Java services API has both.

Is it a good practice to nix the create method and overload the save method such that if the ID is missing a new entity is created? Would this make it easier for clients of this web service? or harder?

+1  A: 

For most web APIs that I've used, they've separated Create from Update in their interfaces.

Frameworks seem to combine these.

So, I'd say, on the server side, combine them to make your coding easier, but keep them separate in the API.

Marcus Adams
+3  A: 

I would say it depends on what your webservice, and data creation/update, mean :

  • If creating a record, and updating a record, are two really different things for you and your users, then, you should have two methods : this will probably be more meaningful.
  • If what matters the most is that the data is saved, then, you could use only one.


I've often seen API that have two distinct methods ; but I've often used libraries that only have one...

I suppose it's because, in those situations, on the API level, creating vs updating matters -- while on a lower level (i.e. data-storage) it doesn't matter much.

Pascal MARTIN