views:

54

answers:

2

Hi all

I have a few webservices (.net 2.0/ C#) used by many partners. One of them want to be able to send an other parameter.

Can I had a parameter to a method and be sure that there won't be any consequences on the other partners whatever technology they use to call us ?

Thanks

+4  A: 

If you alter your method signature, they will have to alter their calls to suit. A better way might be to include a second method signature with the new parameter and alter the code in the background so that the original method calls the new method, with your choice of default value for the new parameter. This ensures compatibility with all your clients.

Paddy
Yeah, the SOLID principles should apply to web services as well. "http://en.wikipedia.org/wiki/Solid_(Object_Oriented_Design)?"
bzlm
My problem here is that I already created 3 other method (MyMethodWithParameter1,MyMethodWithParameter2 etc...) and I want to keep my method list simple.I absolutely agree with the Solid principle but when you deal with developers who have various level of skill you have to keep things simple.
remi bourgarel
If you are having to constantly change parameters, I'd consider creating a method that takes XML as an input, so that can change without changing the method signature. Your code in the background can then deal with whatever the XML supplies.
Paddy
@Paddy Ah, you mean the legendary `DoStuff(object data)` method. Now we're talking.
bzlm
@bzim, quite, although I do believe that it has it's time and place, but that's a particularly specific time and place...
Paddy
A: 

If you are passing a DTO you could add a new property being nullable without problems.

If not it is difficult, I think you can not have two methods with the same name. Maybe create another method for this partner.

Pablo Castilla