Wednesday, November 4, 2009

Locks, locks go away.

Recently we had some team members leave our project, unfortunately they still had some exclusive locks on files within Team Foundation Server (TFS).  To get around this you need to use the TF.exe tool.

The syntax is as follows. 

tf.exe LOCK "$/PathToTheFile/FileInQuestion.cs" /LOCK:NONE /WORKSPACE:WorkspaceOfTheUserWhoHasTheLock;UserWhoHasTheLock

tf.exe UNDO "$/PathToTheFile/FileInQuestion.cs" /WORKSPACE:WorkspaceOfTheUserWhoHasTheLock;UserWhoHasTheLock

Get Amongst It!!!

IOC Containers – Who do they depend on??

I am a big fan of Inversion of Control (IOC) containers.  I strongly believe when used correctly they clean up your code by at least 30% .  They also help you understand your dependencies much better.

There are many options for developers when choosing an IOC, of which most have extensive material, samples and documentation available.  Recently I was wondering what are the dependencies of an IOC container.  After all, they help apply the dependency injection pattern, but what do they in turn rely on.  To help with this exercise, I am using a tool called NDepend.  This is similar to the dependency mapping available in the Beta of VS2010 but on steroids.

I took two containers that I am familiar with.  The Microsoft Patterns and Practices implementation Unity, and the popular open source project StructureMap.

The first thing we notice about both frameworks is that they have little need to go outside the basics of the .Net framework.  As such they are both great candidates for any type of application, be it Web, WPF or services.

Unity Structure Map
DependencyGraphSnapshot image

Delving a little further, we find that both frameworks are similar in the namespaces they consume. Both making strong use of generics (to be expected), however Structure Map has some a fluent configuration options and so makes use of Linq.  It also has some specific implementations (Pipelines) that cover specific lifecycles such as ASP.Net.

Unity Structure Map
DependencyMatrixSnapshot DependencyMatrixSnapshot

Comparing components in this way gives you a better understanding of what is under the hood.  This is just a quick overview of looking at frameworks and their dependencies.  Next time that you use a framework, it might be worth considering what other components and dependencies you are inheriting.

Get Amongst It!!!!

Tuesday, October 20, 2009

Merlba Samples

Over my time as a dev, I seem to constantly need old snippets and code for quite simple tasks.  Some people use snippets, some templates however I have decided to add all mine to an open source project.

Currently hosted on Codeplex (this will be changing shortly) is http://merblasamples.codeplex.com/.  Over time I am going to use this as a bit of a dumping ground for ideas and samples that I have collated.

Case in point, I needed a simple method to allow for converting a legacy apps string representation to Title Case.  So I have added to the utilities.

public static string AsTitleCase(this string s)
{
         var textInfo = Thread.CurrentThread.CurrentCulture.TextInfo;         
         var result  = textInfo.ToLower(s);
         result = textInfo.ToTitleCase(result);

         return result;
}

Get Amongst It!!!

Monday, October 5, 2009

Telerik TFS Project Dashboard

The project I am currently on uses TFS 2008 (Team Foundation Server) and I am always on the look out for new add ins and tools to make life easier.  One I have mentioned in the past is Conchango’s Scrum Process Template.  We are also using Telerik’s suite of ASP.Net controls within the web app we are building.  These two tools now have something in common…

TFS Work Item Manager & TFS Project Dashboard

Set out as a showcase for their WPF tools, it seems to be a combination of the current dashboards  available and the Office integration.

Kanban like??

image

Who broke the build

image

It’s not quite Team City build intergration, however its could make the TFS experience all the more palatable.

Get Amongst It!!!

Friday, October 2, 2009

FIFA 10 GOALLL!!!!!

I haven't played the Xbox in a while, so to have this as my first goal was pretty cool.

Pitty it was not Timmy Cahill.

Get Amongst It!!!


Monday, September 21, 2009

Fluent NHibernate HasOne Mappings

Every now and then you might work with a system that needs to represent a one to one mapping.  This does not occur too often, something that was evident when I did a quick search on Fluent NHibernate’s HasOne mapping action.

Say you have something like the following relationship.

image

You might have a mapping like the following

public class NutMap : ClassMap<Nut>
{
    public NutMap()
    {
        Id(x => x.Id)
            .GeneratedBy
            .Identity();

        HasOne(x => x.Bolt)
            .ForeignKey("FK_Bolt_to_Map")
            .Cascade.All();

    }
}

public class BoltMap : ClassMap<Bolt>
{
    public BoltMap()
    {
        Id(x => x.Id)
            .GeneratedBy
            .Identity();

        HasOne(x => x.Nut)
           .ForeignKey("FK_Bolt_to_Map")
           .Cascade.All();

    }
}

It all works as expected.  One situation I ran into was when a two tables were using the same identifier.  In that case the following code may help.  This is especially helpful in legacy systems which may have normalised tables and when a foreign key represents this one to one link .

Id(x => x.Id).GeneratedBy.Foreign("Property on the entity being mapped who’s id the entity being mapped should use")

Get Amongst It!!!!

Wednesday, September 9, 2009

WCF & IIS Metadata

The other day I was wondering why a new set of WCF services could not be accessed via an AJAX Web site.  These were REST endpoints and all I was receiving in JavaScript was a cryptic error message.

First thing was to ensure the trusty old setting in WCF to ensure the faults were reported through to the client.  This can be done in either the service behaviour or the debug settings for the endpoint.

No luck :(

After further investigation, I realised that IIS and WCF was not registering the correctly for ISAPI.  It was then a case of running the install for WCF for IIS (ServiceModelReg.exe) and all was great.

Thinking back now, I was screwing with some handlers and settings in IIS.

Get Amongst It!!!

Install WCF for IIS

http://msdn.microsoft.com/en-us/library/ms732012.aspx

Include Exceptions

http://msdn.microsoft.com/en-us/library/system.servicemodel.servicebehaviorattribute.includeexceptiondetailinfaults.aspx