Category Archives: Development

Defensive coding with code contracts

I find defensive coding a really great way to improve the quality of a codebase. Code contracts is an implementation of Design by contract (dbc). Dbc was introduced in 1986 by Bertrand Mayer for use with Eiffel. The concept is simple, check that the input to a method is valid and that the return values […]

More StructureMap

In the previous post I talked about strapping up StructureMap with Caliburn. There is actually a much nicer way strapping up the views and common stuff using conventions. private Registry GetRegistry() { var registry = new Registry(); registry.Scan(r => { r.Assembly(“WPFShared”); // Where we keep our common stuff r.TheCallingAssembly(); // Here are all our prsenters […]

Strapping up StructureMap with Caliburn

We are using Caliburn in our current project. Its a great framwork and cuts away much plumbing. You can use all the common DI containers for setting up dependencies. We use Structuremap in other parts of the application. Here is how to set it up for use with Caliburn: (code tags a bit wierd) using […]

Windows services – a nice way to develop, debug and install

A nice way to develop sevices is to start your project with an ordinary console application. Within the console application you can swith input arguments. If there are no input arguments you can start the service and if there is for example “/test” you could do some processing or debug into some code. Some example […]

Two nice tools for getting started with mocking and DI

Mocking and dependency injection can seem overwhelming the first time you read about and try to implement them. Two nice and clean frameworks are moq and ninject They are very easy to get into and both has good basic tutorials. For a beginner they cover what you want to do. I will try to show […]

HttpContext and encodings

Lately I have been running in some trouble with Response encodings. I always forget how I solved this kind of things last time when I run into them so I’ll put it here. The scenario is that we had some problems with swedish (å, ä, ö) turning into junk when saving a textfile. First I […]

Extension methods – good, bad or ugly?

At first glance extension methods looked very appealing to me. The ability to do something like this look very neat at first glance. using System.Text.RegularExpressions; namespace Gyllensward.Examples.Extensions { public static class StringExtensions { public static bool IsValidEmail(this string email) { return Regex.IsMatch(email, @”…”); } } } string email = “”; bool isValidEmail = email.IsValidEmail(); But […]