Scott Roberts <sr******@no.spam.here-webworks-software.comwrote:
<snip>
(Seriously though, if you want more information on any of those, just
let me know.)
I'd like to know your opinions on those features as they relate to
code-readability and maintainability (i.e. do they help, hurt,
or have no effect).
When used appropriately, they can help a lot - but only when you
actually *know* the new language features. For example, until you've
learned how query expressions are handled by the compiler, you can
easily make mistakes and the whole thing is somewhat magic. When you
*do* know what's going on behind the scenes, they're a huge boon to
readability, IMO.
I've been thinking a lot recently about two different aspects of
readability: what your code does, and how it does it. Often an increase
in the former aspect means a decrease in the latter. Extension methods
are a good example of that - they allow you to reduce the extra clutter
of specifying where a static method is coming from, but at the cost of
it not being obvious exactly what's going on.
That's okay so long as all the maintainers know how to find out the
"how" when they need to - but it also increases the risk of "cargo cult
programming":
http://blogs.msdn.com/ericlippert/ar...tax-semantics-
micronesian-cults-and-novice-programmers.aspx
A lot of the features of C# 3 could be overused and cause chaos - but
in the right hands they'll contribute a lot to readability, in my view.
I also suspect that a lot of the fear over some of the features
(implicitly typed local variables, for example) stems from a "but it's
never been like that before" viewpoint. I haven't been immune to this -
I initially hated the idea of implicitly typed local variables other
than with respect to anonymous types, but I now welcome them in many
other situations.
One thing I *would* say about C# 3 is that it's been very, very well
thought out. (That's not to say there aren't things I'd change - the
discovery of extension methods being the most obvious one.) The whole
thing hangs together as a set of changes and is very elegant. I've been
fortunate to spend rather a long time poring over specs etc (as part of
the writing process) which has made me think about the language changes
in a deeper way than I would probably have done otherwise.
In short, I really, really like C# 3 :)
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
World class .NET training in the UK:
http://iterativetraining.co.uk