New in C#4

Bruno Medeiros brunodomedeiros+spam at com.gmail
Thu Nov 6 16:15:48 PST 2008


Ary Borenszweig wrote:
> Robert Fraser escribió:
>> Denis Koroskin wrote:
>>> I once had the following Color class:
>>>
>>> class Color
>>> {
>>>     this (byte alpha, byte red, byte green, byte blue) { ... }
>>> }
>>>
>>> and used it as follows:
>>>
>>> Color c = new Color(255, 0, 255, 0); // opaque green color
>>>
>>> After refactoring, alpha became last argument in ctor:
>>>
>>>     this(byte red, byte green, byte blue, byte alpha) { ... }
>>>
>>> Note that this change didn't raise any compilation error, nothing 
>>> that would notify my of possible error.
>>>
>>> Needless to say that I didn't enjoy searching all the code that used 
>>> Color to reorder parameters (although some artifact were nice :)
>>> It would save me quite some time if I initialized all my instances as 
>>> follows:
>>>
>>> Color c = new Color(alpha: 255, red: 0, green: 255, blue: 0);
>>>
>>> Now compiler could raise an error if parameters order was changed. 
>>> Even better - compiler could reorder parameters for me automatically 
>>> if given that all of them are specified and no params ommited (unlike 
>>> Python). This makes code more robust to refactoring.
>>
>> The first thing  I thought of when reading this is Eclipse JDT's 
>> "Change Method Signature" refactoring that will look up all the calls 
>> in your project & automatically reorder the parameters for you.
> 
> Me too. :-)

Of course I also ate a piece of that cake. ^^

I keep getting the impression that we 3 are the only people in the D NG 
that have used JDT extensively.
That's unfortunate because I feel most people here don't realize how 
much an IDE like JDT (or something comparable, like IntelliJ IDEA, but 
not VS) can shape and improve the development workflow (and thus have 
potential implications in language design).
And it's not something that can be easily understood in foresight - one 
really has to try it out (rich IDE functionality) for some time and even 
then, you might not notice it until it is *taken* from you. Fun story, 
that happened to me:

When I started looking for work after graduation, recruiters asked me if 
I had preference for working with C# or Java. I had no anti-Microsoft 
bias (apparently some people do, even in the workplace), so I judged 
both in terms of language only, and I really didn't have much of a 
preference then (note, this was considering C# only up to version 2.0 
only). I was slightly inclined to Java, but only because I had used it more.
But months later, when I started working on a project that had a desktop 
client, I tried using C# (to take advantage of the WinForms designer) I 
was vexed as Visual Studio (C# 2005) seemed primitive in comparison. 
Suddenly many of the things I had taken from granted were gone, and I 
missed them a lot more than I expected (one example is the Ctrl-1 
"Assign to Local Variable" refactoring which gradually become one of my 
most used refactoring, almost as much as Refactor-Rename). It was almost 
like going from C to BASIC (when I only knew BASIC, it didn't seem so 
sucky).
It has become so that now that I am searching for other job 
opportunities, given C# and Java roles, I am strictly only considering 
Java-based ones (and here in Portugal, C#/.NET has a big market share, 
as big, if not bigger, than Java).


-- 
Bruno Medeiros - Software Developer, MSc. in CS/E graduate
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list