ALLINSIGHT

Home of the AlmostImplementedException

Clean Code

Unexpected behavior of foreach

When a program produces wrong results sometimes(!) your code is not the problem, but the compiled result. Thats nothing new, but most developers are not aware of it. It doesn’t necessarily mean, there is a bug in the compiler. Maybe you (and the rest of the world) just expected another behavior. Today I want to […]

cast vs “as”

Another good example for our categories “difference between a duck” AND “CleanCode” is an ordinary ()-cast against “as”-cast. Why is it in both categories? Both do roughly the same thing and its more a question of code-style which one you use. But more important both use different ways to approaching the same problem and thats […]

For vs Foreach

Sometimes, especially with C# you hear alot of “common knowledge” about performance and developers mistakes. As an (bad) example I want to refer to 8 Most common mistakes C# developers make and in particular point 7 “using foreach instead of for”. So whats wrong with this kind of post? First of all, it refers to […]