Dependency injection - the what and the how

Background: We’ve started a weekly patterns & practices meeting at work with some of our senior developers where our discussions and actions will hopefully bring some improvement to the current development environment. Once a week one of us has an opportunity to showcase a new topic – much akin to knowledge transfer session but more fine-grained and at a higher level than the technology. Gareth Stephenson suggested we blog about the content for the benefit of others, which I think is not a bad idea at all. [Read More]

NGenerics overview - GeneralTree and the Visitor pattern

Previous instalments General Data Structures HashList [ Note : This post feels a little like Computer Science 101 - but I felt it necessary to discuss the basic tree concepts before we move on to some of the more specialized trees like search trees. ] The GeneralTree<T> class in NGenerics provides a way of defining tree structures in a simple, recursive way. It has a simple, recursive definition : public class GeneralTree { T nodeData; List childNodes; } Visually, we can represent it, well, as a tree : In contrast to some of the more specialized tree structures (like binary trees and search trees), the GeneralTree enforces no constraints on the structure of the tree. [Read More]

Specification pattern

The Specification pattern has been added to NGenerics. In my previous post on the Specification Pattern, we explored creating specification functionality using extension methods. It’s actually been implemented with the operator methods (And, Or, Xor) on the actual interface, with an abstract class forming the base of all specifications. The deal-breaker for this approach was the need to add operators |, & and ^ in order to trim down the syntax a little bit. [Read More]

Extension Method Patterns

One of the walls I hit the most in C# when designing classes is the lack of support for multiple inheritance, which makes that one spot for inheriting from a very valuable spot indeed. For the purposes of this discussion, we’ll start with a simple implementation of the specification pattern : public interface ISpecification<T> { bool IsSatisfiedBy(T item); } The evaluation is all set, but now we feel the need to add the boolean operators And, Or, and Not. [Read More]

Sealed classes

As part of version 1.3 of NGenerics, I’ve finally remove most of the sealed keywords from the classes (where it made sense). It took me a while, but I’ve accepted the following rule (and Microsoft is of the same opinion, it seems) : Never seal a class unless there’s a very good reason to do so (like it being internal, security reasons, etc). Programmers using your library will use it many creative ways you can’t even imagine, and sealing a class limits that creativity. [Read More]