Presenting templates for int and string ValueObjects

Most ValueObjects that i have implemented were wrappers around an int or a string. Apart from the domain specific rules, there is a lot of repetitive work in implementing operator overloads, IEquatable<T>, IComparable<T>, … Thus i decided to create a couple of Item templates that generate this code (and related tests).

Simply save IntValueObject.zip and StringValueObject.zip under %My Documents%\Visual Studio 2005\Templates\ItemTemplates and click on “Add New Item” in your project:

screenshot of add new item dialog in visual studio

Add the bottom of the dialog you can choose one of the templates:

screenshot of add new item dialog in visual studio

Here is the result of adding an International Standard Book Number class:

screenshot of generated artificates for isbn

This entry was posted on Friday, September 26th, 2008 at 17:01 and is filed under C#, Visual Studio. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

One Response to “Presenting templates for int and string ValueObjects”

  1. Tim Van Wassenhove » Archive » Revisited the int and string ValueObject templates says:

    [...] reading The Compare Contract last week i realized that my templates for int and string ValueObjects did not comply with the contract so i decided to add a unittest that reproduces the faulty behavior [...]

Leave a Reply