This is the number one reason I love static analysis tools like ReSharper for coding.  I write a piece of dodgy code, and it tells me &quot;Hey, this could result in trying to access a null pointer&quot;, or, &quot;Hey, dummy, this conditional is logically inconsistent and the block below can never get executed&quot; or &quot;Hey, you can rewrite this great big loop with a simpler LINQ statement.&quot;  Then after a few times of doing this, I internalize the rules, and start doing it on my own.