Tuesday 23 August 2011

Evil Linq!

I love Linq. Most of the time it helps us do some clever stuff in an elegant, fluent way. Recently though, I have come to dread seeing certain kinds of Linq statements.

The biggest problem I have with Linq, is that it encourages you to write sloppy code, with no error handling at all. This is fine in theory as we 'should' just let exceptions propagate, but in the real world, where you have users editing the content, I have seen many a site go down because someone didn't check for null when getting something out of the repository.

The other issue with Linq is readability and a painful debugging experience. If you use ReSharper like me, you will often get suggestions to covert loops to Linq queries. Fine in theory, but if you have 3,4 or even 5 clauses to it, it quickly becomes painful to read. Combine this with the fact that you can't execute lambdas in the immediate window ( seriously Microsoft - wtf?) and you are in a world of hurt.

Linq makes stuff ugly sometimes, don't do everything resharper tells you kids!

No comments:

Post a Comment