3 ms·
How about implicit interfaces in C#?
- nopassrecover 17y agoBy implicit interfaces I believe you mean inferred interfaces in the same way that 'var' is inferred typing - type/interface definitions still exist, but you would like their assignment to an object to be inferred. I don't think this is particular helpful. For instance, many interfaces share the same method signatures (although perhaps not the same collection of method signatures) so assignment is unlikely to be accurate and the resulting behaviour of treating an arbitrary object as an implementor of a particular interface seems unlikely to be desirable. For instance, just because I can run and a river can run does not mean we should both be entered into the 100m dash at the olympics. However, I'm open to positive examples that are more beneficial than saving a few letters on your class definition. What I find interesting (and plan to develop into a longer piece of writing) is an investigation of the general idea of implicit interfaces combined with something like Yegge's prototype pattern (http://steve-yegge.blogspot.com/2008/10/universal-design-pattern.html http://steve-yegge.blogspot.com/2008/10/universal-design-pat...). The details are still hazy in my mind but an elegant way of requiring that the object passed into a method meets particular conditions at runtime sounds pretty cool and useful to me.