25 Jul
2009

Generic Expression Builder

I blogged about fluent interfaces and expression builders a couple of times before. For this post, I want to share a base class that I’ve been using for taking away some of the burden when creating expression builders for domain classes. Here’s the expression I’m after: var document = DocumentBuilder.BuildDocument() .AuthoredBy(“Stephen Hawking”) .Titled(“The Universe in […]

Read More
14 Jul
2009

MOQ Mothers

Category:UncategorizedTag: , , :7 Comments on MOQ Mothers

Am I the only one who does this? I like to use Object Mothers in my test projects, especially when I have a large number of services or entities I need to feed into the things I am testing. For example, if I have a class I am testing that takes a constructor argument, I […]

Read More
3 Jul
2009

WPF Multithreading: Using the BackgroundWorker and Reporting the Progress to the UI.

I can’t count the number of times someone has asked me about running a time consuming task on a separate thread, but at the same time show a progress dialog with up-to-the-second percentage updates being displayed to the user. Multithreading can be confusing at first, but if you just take it one step at a […]

Read More
19 Jun
2009

Refactoring XmlWriter

Category:UncategorizedTag: :14 Comments on Refactoring XmlWriter

I inherited some code that make heavy use of XmlWriter.  Say what you will about XmlWriter, it works, but the code using it can be ugly, hard to read, and hard to figure out where you went wrong.  Case in point, there were numerous errors in the code that went unfound by the unit test, […]

Read More
7 Jun
2009

Generic Value Object

Category:UncategorizedTag: , :16 Comments on Generic Value Object

I just wanted to share my attempt for implementing a generic base class for Value Objects, popularized by Eric Evans and the Domain-Driven Design community. I must say that I got heavily inspired by Jimmy Bogard’s implementation, which got me thinking about such an approach. Contrary to his implementation, I used static reflection instead of […]

Read More