Thursday, April 23, 2015

Offer a default value for loose coupling only.

One cool thing about named and optional arguments in C# is that one may have an an optional arguement at an interface's method's signature without having to make a class implementing the interface also specify an optional argument at its own dance partner method's signature. I'm not yet sure about how overriding/hiding methods a parent class works along these lines. Things will not work the other way around for interface and implementer. You may not have an optional variable at the implementer and just leave that bit of the method signature off at the interface and get away with it.

 
 

Addendum 6/14/2016: I a rereading this and wondering what I meant. If you have something like int? id=null at the method signature in one place (interface or implementing class) you have to have it in the other.

No comments:

Post a Comment