Ray's playground

 

Item 10: Use Optional Parameters to Minimize Method Overloads(Effective C#)

  Therefore, adding parameters, even if they are optional parameters, is a breaking change at runtime. If they have default values, it’s not a breaking change at compile time.
  Now, after that explanation, the guidance should be clearer. For your initial release, use optional and named parameters to create whatever combination of overloads your users may want to use. However, once you start creating future releases, you must create overloads for additional parameters. That way, existing client applications will still function. Furthermore, in any future release, avoid changing parameter names. They are now part of your public interface.

posted on 2011-01-18 21:16  Ray Z  阅读(207)  评论(0编辑  收藏  举报

导航