There is more than one way to linq that

Eric Gunnerson has a post in which he responds to Justin Etheredge regarding “Is Programming A Generic Skill?

I’ll just say that I agree with them both. There are differences between ability, proficiency and mastery.

A Java programmer can jump into C# and be an able C# programmer immediately. It will take time to become proficient and even more time to develop mastery.

I am proof of this with python. I’ve been an able python programmer for over 10 years now(actually closer to 15), but I never spent enough time in python to call myself proficient and I’m certainly far from a master.

But the thing that Eric said which triggered me to write this is not the generic skill discussion with Justin, it is instead a remark that Eric said about Perl, “… because of TMTOWTDI”.

C# is very much becoming afflicted with There is More Than One Way To Do It. It certainly is both the language and library.

Consider LINQ. LINQ to Objects is a new way to do something which everyone has done differently in the past. When new programmers are exposed to linq, I often hear the question “When do I use linq?” The answer I give is typically “whenever you would use a for loop or foreach loop and if you can’t, figure out how you can".

If we throw away the ‘idiomatic code” to which Eric refers, then a giant bucket of TMTOWTDI is thrown in our face. Do we use properties or fields, events or delegate fields?

For public interfaces, FxCop helps a great deal with guidelines for these things and helping to learn the idioms of the language and framework, but for other things, you are left to yourself. That is why reading others source code is so important. (see the weekly course code)

Expand into libraries and TMTOWTDI explodes. From MSFT alone there is Remoting, Web Services (asmx), WSE, WCF, RIA Services, ASHX, ASP.NET Data Services, all of which have some overlap. Then for data access there is ADO.NET, Linq2Sql, Entity Framework. Even within ADO.NET alone, TMTOWTDI. Do you use a reader? Table Adapter with DataSets? Strongly Typed DataSets?

Open to non MSFT and TMTOWTDI explodes again, to the point where I won’t bother listing anything. There is too much.

I think that library TMTOWTDI will always exist. Even Python has SqlObject, SqlAlchemy and ORM as parts of other frameworks like Zope and Django. But language TMTOWTDI is reasonably well mitigated in Python. This is stated in a single line in PEP20 – The Zen of Python

There should be one—preferably only one –obvious way to do it.

C#, perhaps because it was not a goal and because of its C/Java/Delphi roots, has never had that. There has always been TMTOWTDI in C#.