المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Do Lambda expressions smell?



C# Programming
07-30-2011, 07:12 AM
I saw some nasty code recently. A function took a parameter of a type that was something like Func. You get no clues about the parameters.

When (if ever) should we use Lambdas? They seem like a shortcut which will save some time during the initial development, but lose more time later. I think the old fashioned way will almost always be more readable.

One place where lambdas tend to be useful is when using LINQ (to SQL or Entity Framework). Is it really that good though? SQL is designed for the job, and performs MUCH better, so why use LINQ to SQL? If we have automated tests then we can fully test that the code is correctly wired up to the SQL.