What's so bad about ref parameters?

后端 未结 12 604
隐瞒了意图╮
隐瞒了意图╮ 2021-01-11 09:49

I\'m faced with a situation that I think can only be solved by using a ref parameter. However, this will mean changing a method to always accept a ref parameter when I only

12条回答
  •  迷失自我
    2021-01-11 10:13

    If your method only needs this ref parameter 5% of the time perhaps you need to break this method down. Of course without more details its hard to say but this to me smells like a case of violating single responsability principal. Perhaps overloading it will help.

    As for your question there is no issue in my opinion passing a parameter as a reference although it is not a common thing to run into.

提交回复
热议问题