Basically I look at two different situations:
A method call inside one class:
public class MyClass { public Bar GetDefaultBar(Foo foo) { Contract.Requires(foo != null); return GetSpecificBar(foo, String.Empty); } public Bar GetSpecificBar(Foo foo, string name) { Contract.Requires(foo != null); Contract.Requires(name != null); ... } }
Method invocation in different classes:
public class MyClass { private MyBarProvider { get; set; } public Bar GetDefaultBar(Foo foo) { Contract.Requires(foo != null); return BarProvider.GetSpecificBar(foo, String.Empty); }
I am wondering if you need to have duplicate contracts for any of these situations? I suppose there might be a way to avoid this in the first example (all within the same class), but not in the second example (different classes). Also, should duplication be avoided or be there?
source share