views:

1744

answers:

5

Hi there,

Currently have the task of designing a web service ( i am going to wcf but principles still apply) in c#. Problem is there is no overloading of methods which i am aware of so i need to name web methods with different names.

I would really like some input on naming conventions, there just doesn't seem to be anything out there - for example.

My main method is GetMortgages() - which returns all mortgages. I need another one where it will return mortgages within a certain price range so what would you recommend for this GetMorgagesPriceRange, InPriceRange, WithPriceRange.

I am little confused about best practices fro naming web methods, i would love to just overload GetMortgages but of course with web services i can't...

So would it be better to do GetNounDesciption??

Anyone know of any good webservices out there that has a method that is the same but each method has different parameters passed - really like to know about anything here

If it get practice to start my webmethod with GET if it is something that returns something??

What about something that saves and sends something, is there a standard here?? i.e. PUT or SAVE ???

There must be some kind of book of rule to follow??

Really would like some input is anyone has any

Thank you Mark

+3  A: 

There really isn't any "rule book" for naming conventions. You find one that works for you.

The most common adoption with .Net is to follow the Microsoft .Net naming conventions, and with Web Services, just treat them as an extension of your assembly, not as a special case.

http://msdn.microsoft.com/en-us/library/ms229045.aspx

So, GetMortgages(), GetMortgagesInPriceRage(startPrice,endPrice), etc... is fine.

As far as "saving", a lot of people will use the "SubmitNoun".

Tom Anderson
A: 

I think you're doing fine. Describe them based on what it is they're doing. GetAllMortgages(), GetMortgagesInPriceRange(), etc.

Take into consideration any domain-specific terminology. For instance, if the mortgage-industry term for a price range of a mortgage had been "Demographic", then GetMortgagesForDemographic would be the better name, even if you know that the only "demographic" features are the price range.

John Saunders
A: 

You could go with repository-pattern if you have repository-like service (as I assume by your examples you have) convention

GetXByY(params)
Krzysztof Koźmic
A: 

Also, you should probably avoid overloading web service methods. Use distinct method names.

+2  A: 

You could also have the GetMortgages() service method take a 'document' instead of parameters and design the optional filter criteria in the document. That way you have only one method that handles all 'overloads'.

<GetMortgages>
  <filter> .... </filter>
  <sort> .... </sort>
  <group> .... </group>
</GetMortgages>