Archive for February, 2009
What’s in your wallet?
I’ve refrained from posting on the stir that occurred after Stack Overflow #38. I’m firmly on the side of the apparent “SOLID”-nista’s. The reasons for this is that learning and applying them has made me a better programmer. I’ve used TDD and SOLID principles on large codebases and found that this has allowed significant changes and evolutions to happen to these libraries and have them rolled out into numerous separate projects with absolutely no issues. Why? Because there are several hundred tests surrounding each of these projects. And the use of the SOLID principles has allowed me to swap out large sections of code with better implementations and add new functionality with little effort thanks to the reduced dependencies. › Continue reading
Custom LINQ Operator?
K. Scott Allen has a great post up titled Why Would I Create A Custom LINQ Operator? I figured I’d add my minor addition to the discussion.
public static bool Contains<T>(this IEnumerable<T> enumerator, Predicate<T> predicate)
{
if(enumerator == null)
throw new ArgumentNullException("enumerator");
if(predicate == null)
throw new ArgumentNullException("predicate");
foreach(T item in enumerator)
{
if(predicate(item))
return true;
}
return false;
}
This allows you to do this:
if(tags.Contains(x => x.Name == "Coolest Blog Ever")) {
// we found a matching tag
}
else {
// no tag found
}
Nothing special I know, but hopefully it helps someone out.