question on anonymous type

  • Thread starter Thread starter timor.super
  • Start date Start date
Arne Vajhøj said:
I don't think that apply very well. A rather big percentage of Java
programmers also program in C#.

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.
But what I do with o.m() actually depends on what o is !

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. When
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.
(Usually it's still pretty obvious what the type actually is, IMO.)

The aid to the skimming mode is significant though.
 
Jon said:
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.

I don't even think C# would have gotten it if it had not been for LINQ.
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.
When
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.

Arne
 
Arne Vajhøj said:
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.
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 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top