IEnumerable and LINQ

3 minute read Published:

I cannot stress enough the importance of knowing how LINQ queries work when they are based on an IEnumerable source. When one defines a query based on an IEnumerable source, the query variable represents just that: the query, NOT the results of enumerating the query. Each time you enumerate over the query object, you are calculating the results of that query on-demand. There is no caching of results. The LINQ IEnumerable implementation makes no assumptions that enumerating the same query twice in a row will produce the same results and so it let’s you do so without any qualms.

T4 templates with reflection

4 minute read Published:

After redesigning our data, business, and services layers to be interface driven, I wanted to keep the amount of boilerplate code written by developers down to an absolute minimum. The best way I know how to do this is through code generation. T4 templates are a good solution to this problem. T4 might not be as well known as other popular code generation tools but the fact that you get it for free and it’s integrated into Visual Studio is a very strong selling point in my opinion.

Interview Questions for C# Developers

3 minute read Published:

Most of the time when asked to give technical interviews, I do a quick search to find some good thought-provoking and information-providing interview questions. Every single time I’ve come up with some of the most appalling lists of questions that are based on regurgitation ability or that are too insanely technical or trying-to-be-too-clever-and-tricky to be useful to the interviewer at all. Now, I am not one to shy away from technical details by any means.

Strongly-typed Identifiers and T4 Templates

5 minute read Published:

I would like to share with you a Visual Studio T4 template I use to generate strongly-typed identifiers for my domain models. These strongly-typed identifiers are glorified int wrappers. When designing your domain models you should choose to store references as strongly-typed identifiers because it exposes yet another layer of abstraction. Your domain models should never have to know if they reference one another with int, long, string, Guid, or any of the other myriad of identifier types commonly used.

Object models and Interfaces

6 minute read Published:

Whatever I design I’ve noticed that I always opt for flexibility first, followed closely by simplicity, performance, and maintainability (in no particular order of preference). Allow me to share with you a recent product of my own design process as it applies to n-tier architecture for solving general business problems. In this proposition, dear reader, allow me to assume that you have at least a passing familiarity with n-tier design. Also please let me assume you have first-hand experience in working as a developer within a team striving to develop and complete a software product.

XP SP2 Connected USB Hard Drive not displaying in My Computer

1 minute read Published:

Just ran into this lovely issue here… I connected up a USB HD, a Maxtor BlackArmor, and it wasn’t displaying in My Computer at all. It turns out that under some random circumstance, the Maxtor device was mapped to J: in Disk Management, while simultaneously, a network drive was mapped to the same drive letter by my employer. The network drive takes precedence and so that is what shows up mapped to J: in My Computer and the Maxtor device will never show up.

Why Doesn't It Work?

3 minute read Published:

Debugging, or diagnostics, is a critical skill for any good developer. It is engineering at its core; problem-solving perfected in art. There is no One Good Way to diagnose a problem, but I have discovered an excellent process that I employ regularly to almost unfailingly diagnose software engineering problems. Mindset Too often I hear the question, “Why Doesn’t It Work?” Why do we ask this silly question? What past experience in our lives has taught us that things should Just Work ™?

libevent for .NET / C# / Managed C++

1 minute read Published:

Ever wanted to write your own scalable .NET managed server applications? You can using libevent’s .NET managed wrapper that I just wrote! libevent is a C library useful for creating extremely scalable server applications in unmanaged code. I couldn’t find a managed .NET wrapper for this library so me being Mr. NIH I invented it myself. In actuality, it wasn’t that bad! Managed C++ is an interesting beast. For the TL;DR crowd, here’s the SVN repository¬†for the project including source code and compiled assembly.

A tale of caching strategies

4 minute read Published:

Let me regale you with the tale of my most recent endeavour into the realm of caching strategies… In developing an in-house content management system for ASP.NET, I knew that there was going to be lots of content developed and stored in the database-backed system. I also knew that the system would need to be deployed on a web farm, so the default in-memory ASP.NET cache provider was not going to serve me well here.

Memcached Primer

3 minute read Published:

Memcached at its core is a simple network service that acts as a hashtable with an easy-to-use ASCII-based protocol for communicating with it over a TCP socket. You can even telnet into it and give it commands yourself, but I wouldn’t recommend this for anything but the most simplistic ‘stats’ and ‘flush_all’ commands, which can be very handy. It is really meant to have application clients connect to it (default configuration allows up to 1024 simultaneous connections) and have each client tell it what to do.