Re: question on anonymous type



Arne Vajhøj <arne@xxxxxxxxxx> wrote:
In which case it would be interesting to see whether it becomes more
requested in a few years' time, when those developers have been using
C# 3 and become used to "var". It's too early to take results *now* and
draw any conclusions.

True. It could change.

But I doubt it will happen. It is not exactly a new concept.

It's not a new *concept* but it may be new in *practice* to a lot of
people. Heck, I'd never used a lambda expression in anger until C# 3,
and those have been around for ages too.

I don't even think C# would have gotten it if it had not been for LINQ.

Quite possibly not - but that doesn't mean the feature isn't handy
outside LINQ. Extension methods could be thought of in the same way,
and those *are* on the cards for Java 7.

But if it's obvious when *reading* the code what's going on, the
details only matter when you're looking more deeply into the code.

I don't consider the type a detail in OOP.

I do when it's a matter of skimming code. Do I care whether I'm using
an array or a List<T> if I'm just indexing it? Not really. Do I care
whether something is definitely a LinkedList<T> or any old
IEnumerable<T> if all I'm doing is iterating over it? Not really.

Bear in mind that the declared variable type won't tell you what the
actual type is anyway (unless it's a sealed type) - if you need that
information you've *got* to look to the right hand side of the
assignment. If you're going to do that, how much do you care about the
LHS?

I'm not saying it isn't important information - just that I don't find
it important in certain modes of reading code, and those modes account
for quite a lot of the time I may spend reading code (either for
debugging and trying to get to the critical spot quickly, then
understanding that critical spot in detail, or just getting the flavour
of a class).

But hey, it's definitely a style thing. If you don't like it, that's
fine.

I'm working on a problem, I don't actually need to read most of the
code closely - I'll skim a lot of it. Implicitly typed local variables
help the skimming mode, and arguably slightly harm the detailed part.

I believe many people will want to know the type even for skimming.

Then I believe they won't skim as quickly as they can, for the basic
level of "what's this method trying to achieve?" that I aim for with
skimming.

--
Jon Skeet - <skeet@xxxxxxxxx>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
.



Relevant Pages

  • Re: What? Am I Ms. Pariah or something?
    ... Actually it's been pretty mellow on AGRO lately, you been missing out ... aggressive skimming skills probably miss alot of important stuff. ... Don't you even care that I sat here and wrote from my heart about how I ... I wanted folks to feel like I do, ...
    (alt.gathering.rainbow)
  • Re: WSOP decisions
    ... It's not just the unfairness of the blinds, introducing new chips (which ... It doesn't mean they are skimming, but it does mean they don't care about ... it's not their money at risk, it's players money. ...
    (rec.gambling.poker)
  • Re: Intervalic Improvisation By Walt Weiskopf
    ... If this is just "skimming the surface" then I 'm in trouble - looking ... at the charts at pages 20 to 23. ... let me skim along for ...
    (rec.music.makers.guitar.jazz)