Is it bad practice to have an output parameter in a method in a WCF service?

后端 未结 2 1692
春和景丽
春和景丽 2021-02-08 07:36

I\'m looking for reasons beyond the usual \"out parameters are confusing and indicate the method is doing more than one thing\"-style arguments and more about what is specifical

2条回答
  •  忘了有多久
    2021-02-08 08:16

    One reason is the out parameters are handled by the proxy class generated when you add the service reference - that's extra overhead.

    Another reason: according to this post, even if the original out parameter is last when you consume it, it becomes first - confusing and may lead to complication errors that might take time to solve until someone figures this out.

    Personal opinion: WCF operation (method) should do something and return something. It might do lots of things, but return only one thing which is the result - if you need extra stuff just have it return complex type with everything you need as data fields of that type.

提交回复
热议问题