Re: [Proposal] Named and Optional Parameters with Default Values
- From: Andreas Mueller <me@xxxxxxxxxxx>
- Date: Mon, 12 Jun 2006 21:18:15 +0200
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
.
- References:
- Prev by Date: Re: Application Data Caching
- Next by Date: Re: Looking for practice programming problems
- Previous by thread: Re: [Proposal] Named and Optional Parameters with Default Values
- Next by thread: Re: Named and Optional Parameters with Default Values
- Index(es):
Relevant Pages
|