.net - Extension method design guidelines: should a like method name be the same for the sub and super class? -


i finished reading section on extension members in framework design guidelines 2nd ed., krzysztof cwalina , brad abrams, , didn't find example this. question concerns super , sub class in f# library, expect answer relevant .net languages.

f# has 2 types, super type expr , sub type expr<'a> latter wrapper typed version of former. these types used quotation expressions.

if wanted define extension methods on these types evaluating them, better design:

  1. do f# powerpack , defined methods different names evaluntyped() : expr -> obj on expr , eval() : expr<'a> -> 'a on expr<'a>.
  2. do closer if owned types , use same name (where method on super type can thought of virtual, , method on sub type can thought of overriding super virtual method). i.e. eval() : expr -> obj on expr , eval() : expr<'a> -> 'a on expr<'a>.

the second option seems more correct me, i'd follow whatever design guidelines there may be: there authoritative precedence (supposing got "wrong" in powerpack)?

there may not definitive answer this. however, unless believe f# powerpack did design "wrong", i'd follow style 2 reasons:

  1. to keep style consistent other developers work in f# , official extensions.
  2. to more explicitly show difference in return types of 2 methods since matter.

your analogy in reply tomas one, i'd assume other developers using code may not pay attention design have. best keep consistent official style , explicit in intentions.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -