Item 10: Use Optional Parameters to Minimize Method Overloads(Effective C#)
2011-01-18 21:16
459 查看
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.
相关文章推荐
- Item 39: Use Dynamic to Leverage the Runtime Type of Generic Type Parameters(Effective C#)
- Item33 Use decltype on auto&& parameters to std::forward them
- Item 33: Use the new Modifier Only to React to Base Class Updates(Effective C#)
- Item 36: Understand How to Use PLINQ for I/O Bound Operations(Effective C#)
- Item 40: Use Dynamic for Parameters That Receive Anonymous Types(Effective C#)
- Part 67 to 70 Talking about method parameters in C#
- Use code to approve SPListItem
- Item 22: Prefer Defining and Implementing Interfaces to Inheritance(Effective C#)
- How to store scaling parameters for later use
- Effective Objective-C 2.0: Item 35: Use Zombies to Help Debug Memory-Management Problems
- Effective C#之Item 41:Prefer DataSets to Custom Structures
- When to use static method in a java class
- (Item 1) use static factory to substitute constructors
- Item 8: Prefer Query Syntax to Loops(Effective C#)
- “The signin method you’re trying to use isn’t allowed&rdquo
- Use Y method to solve Problem X
- Effective C# Item 1: Always Use Properties Instead of Accessible Data Members
- Using the isBranch() method to determine if a Tree item is a branch or leaf
- How to use 'SetItemData()' and 'GetItemData()'?
- Effective C#之Item 42:Utilize Attributes to Simplify Reflection