Re: [Proposal] Named and Optional Parameters with Default Values

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



cody wrote:
I got a similar idea a couple of months ago, but now this one will require no change to the clr, is relatively easy to implement and would be a great addition to C# 3.0 :)


<snip/>

So what do you think? Is it just another stupid idea or may it be worth the effort and valueable for csharp programmers?




I really respect the effort that you have put into this post, but I think (based on my experience) that this is not a simple feature at all.

Let's take a look at your slightly extended example:

class Base
{
public virtual void Open(string path,
AccessMode mode = AccessMode.Read,
int bufferSize=1024)
{
// ...
}
}


// derived class
class Derived
{
public virtual void Open(string path,
AccessMode mode = AccessMode.Write,
int bufferSize=1024)
{
// ...
}
}


Base b = new Derived();
b.Open("..");

Is it open for read or for write? And this is just a starter! I just have to dig in my dark memories of the C++ world... Just think about shadowing a method with "new", overloaded methods that are scattered over an inheritance hierarchy, abstract methods and last but not least interfaces. It is sure possible to define a meaningful behavior for all of it (it was possible in C++), but this isn't a simple and easy feature than anymore. Actually it is one of the pitfalls that Scott Meyers mentions in his famous Effective C++ books.

Maintenance/Feature development (Keeping alive the features you have and add new ones ) is the most difficult part in a software project. Maintenance is done by reading and interpreting code so that you can extend or refactor it. Features like this in the best case add an unnecessary difficulty to it, because now I have to take default variables into account.


Cheers,
Andy
.



Relevant Pages

  • Re: Configuring Firewall
    ... like the feature of being able to see which ports and remote ports that ... This feature was very useful when I was setting up a server-like ... Very annoying, but relatively easy to ...
    (comp.security.firewalls)
  • Re: closing unit=5 and unit=6 and print *
    ... ifort W_FC_C_9.1.028 ... Lahey/Fujitsu Fortran 95 http://www.lahey.com/check.htm ... Since this is a relatively easy feature to add, ...
    (comp.lang.fortran)
  • Re: [PATCH] capabilities: introduce per-process capability bounding set (v10)
    ... This feature makes me being interested in. ... The following PAM module enables to drop capability bounding bit ... PAM_EXTERN int ... int argc, const char **argv) ...
    (Linux-Kernel)
  • Re: byte + byte -> int
    ... is in range for an int, but allows the line ... overflow, and the rules specifically address overflow. ... it thinks precision might be lost in a down-conversion. ... had one nice feature that our sleek fast modern machines have lost: ...
    (comp.lang.java.programmer)
  • Re: C from Fortran Calls
    ... ``a'' is a pointer to int. ... //~ add point to geometry ... OGRFeatureH feature; ...
    (comp.lang.c)