New in C#4

Ary Borenszweig ary at esperanto.org.ar
Thu Nov 6 16:57:54 PST 2008


Bruno Medeiros escribió:
> 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).

I recently discovered you can do the same with Ctrl+2, L :-)

Of course in D that'll be

auto whatever = <your expression here>;

Do here's a clear example where a language helps not being repetitive, 
and that kind of shortcut becomes less useful.

But refactoring is an essential thing in TDD, and I think that can't be 
easily supported by any language without using a proper IDE.

I also have the sensation we are the only guys that used JDT. In my 
workplace everyone feels very, very comfortable using Java; not because 
of the language itself, but because of Eclipse. It's amazing the speed 
boost you get once you get used to it. You don't have to look at 
external documentation files, you don't have to read someone else's code 
to understand what's going on. You don't need to remember lots of names, 
where's everything is located.

But, as Bruno says, you can't really feel it unless you try it.



More information about the Digitalmars-d mailing list