If when developing in a team, you add code that will require maintenance in order to add new code in that area, then you have a couple of choices: A – Document and communicate B – Refactor to remove the complication, OCP. Ignoring A and B is like loading your credit card, it will become […]

The Spotlight effect – Estimating brownfield changes.

Just a note to myself to add some contigency to estimates where you are making significant changes to an existing area in the code. Basically when you put things under the spotlight you will find things. More often than not you will need to fix or change what was previously coded. This can be weighted […]

Large Entity Framework Models

These are my research notes on coping with large entity framework models. The current community consensus appears to be that the designer will slow up and become less to unusable around the 200+ entity mark. Additionally a single model will not allow you to work across databases and is complicated to work with. So given […]

Reassembling your website with Resharper 6

I recently found myself in the position where I needed to reassemble an ASP.Net site from its deployed files. The first part was easy, create a website project and pull in the front-end files, then it was on to the harder parts, recreating the backing code and making sense of the minified files. The first […]

Returning a cast result from a generic method.

I recently needed to cast an object from the Enterprise Library Caching block back to a type, but start getting the popular System.NullReferenceException error in my tests if the value returned from the caching block was null. The problem is that you cannot cast null back to a non-nullable type like an int. The answer […]

Create your own visual studio output window.

It can be handy to write messages to custom output window/s… Here is some code to do that: Usage EnvdteHelpers.WriteMsgToCustomPane(“WCF”, “Hello”); Helper public static class EnvdteHelpers { private static OutputWindowPane _outputWindowPane; private static OutputWindowPane OutputWindowPane(string paneName) { return _outputWindowPane ?? (_outputWindowPane = CreateOutputWindowPane(paneName)); } private static OutputWindowPane CreateOutputWindowPane(string paneName) { var dte = (DTE)System.Runtime.InteropServices.Marshal.GetActiveObject(“VisualStudio.DTE”); var […]

Lazy load property the resharper way.

Just some more reshaper magic… Resharper took this public IThing Thing { get { if (_thing == null) _thing = new Thing(); return _thing; }} and re-factored it to this which is obvious when u look at it… public IThing Thing { get { return _thing ?? (_thing = new Thing()); }}

MVC, Building and persisting view models.

On my recent projects there has been a higher demand for richer UI with pages containing a number of smaller steps (page updates) before the final submission. In order to do this you will probably need to persist the collection of data between posts, here is one method of tackling this whilst keeping to the […]

Squashing your old sql scripts into migrations using T4 templates.

I recently looked at pulling some old sql scripts into a series of versioned migrations, here’s how the first cut panned out… To get started download MigratorDotNet and the T4 Toolbox. Install the toolbox and then create a new c# class project referencing Migrator and Migrator.Framework. Create an Extensions folder and add MigratorExtensions.cs. using System; […]

.Net 3.5, [Obsolete] and XMLSerializer.

Here my first Gotcha, if you put an [Obsolete] attribute on a class/property then it gets ignore by XMLSerializer, applies to .Net Framework 3.5 and above.