Archive for June, 2008


Results of SourceMonitor on my current project

June 29, 2008

Well last week Richard from Readify had been called in to help us here at my current engagement – Carlson Marketing. While he was here he pointed me to a few programs that I had not known about. One of them was called SourceMonitor. What it does is basically run some metrics against your code to see how clean and how well/poorly written your code is. Before I start keep in mind that the max code complexity and average code complexity should be between 5 and 15. We ran it against some of the code that was contracted off to an offshore company in india and the results that came back were extremely poor (max code complexity of 80). Rather than bagging out what a poor job they had done I decided to see if my own code that I had written myself was any better. I consider myself to be fairly padantic about the way code is written and try to keep it simple as best I can. I decided to run it against one of my more complex projects here to try and get my worst case scenarios. Here are the results SourceMonitor-profile-code-complexity-metrics


as I suspected one of my methods is too long and is too complex. The method basically maps a business object from a web service that’s hosted somewhere across the world. There are many properties on the class that need to be mapped each with fairly complex business logic(s). From this we can see that I have not written enough comments and have a single method that is slightly too complex. On average tho we can see that the rest of the code is fine. It is one problematic method that is throwing everything off a little. I have not gone back to refactor this code as it has been code reviewed by fellow senior devs and we agree that it is an exceptional case and that it is written well. The idea isn’t to stick between the green area 100% of the time but rather to get a rough idea on how well your code has been written. If you genuinely write clean, simple code, I think you will be surprised at how often your code will hti the sweet spot of that green circle.

Here are the results of the code that the offshore company had written: offshore-company-code-complexity-metrics

As you can see the max code complexity is 80 and the average code complexity and comments is off as well.



SourceMonitor is a great way to make sure your code is clean, simple and most importantly – understandable. It is NOT something to be followed as bible but rather a guide.


TFS Build running out of space.

June 23, 2008

This morning all our builds started failing with the following in the error logs

the reason was because the drop location directory had accumilated too many builds and had run out of space. Rather than deleting the builds through explorer in the drop location you should remove them through TFS so that TFS knows about it.

Here is the command to do so: TfsBuild delete <TeamFoundationServer> <TeamProject> <BuildNumbers> [/noprompt]


My Windows Mobile App Idea!

June 18, 2008

So I lost my phone yesterday. I’m going to get a smart phone for my next phone with GPS and this time i’ll create an app so that when it receives a message it scans the content of the message for ‘find me password=xxxx’ and it will then send its gps co-ordinates to a predefined email address and phone number. once I have these I will then be able to track the phone down using another GPS device.

I am looking at getting an IPhone so I may have to learn some non .net language for this…


Project Reference Coupling vs Unit Test Value.

June 13, 2008

Today I had a very interesting discussion with my colleagues at work. Before I dive into what the topic was, it is necessary to give some background of the architecture of the code.

We have split up both conceptually and physically our order management system from our online store. From here on the online store (containing 20+ projects) will be called “Online Store Solution” and the order management system(containing 4+ projects) will be called well… the “order management solution”. The way they communicate is through WSE 3.0 Web services. One cannot function without the other as they are dependant but we have decoupled them in a sense that both solutions are buildable without each other. There are no direct project or DLL references between the 2 solutions. Still, they just can’t do much with out each other. Now that I have explained that we can continue on with my story of what happened at work today. The online store solution had some new project that I added and so I also added a new unit test project to go along with it. One of those unit tests was a data driven test. It required that I store something that was generated in the online store solution, in the order management solution. The problem was, that if I used any of the existing methods from the OMS (Order Management System) that they would be filtered through the business logic (all 1000+ lines of code worth) and so it was not feasible to generate some test data to satisfy all these business rules. So the sharp people out there might be saying by now, why not mock the test? Remember, it is a data driven test so mocking it defies the purpose. So what I did was, add a dll reference to the DAL from the test project in the online store to the order management solution and thereby cut out all the business logic. Now essentially what I have done is introduced a coupling between the projects. This is merely a development experience coupling though. The integration coupling already exists and has not changed. Now here’s the interesting bit. We all expressed our opinions and views on this and came to the conclusion that the team would rather comment out the whole unit test and dump it than keep the reference coupling. They stated that in some time in the future we could spend the time in creating some dummy data that satisfies the complex business rules but obviously that time will be… never. I ended up finding a good alternative which I won’t state here because it’s out of scope for this blog post but my interesting point in this story to make is that some developers would prefer a decoupled solution over unit tests. Not a move I personally agree with. What do you think?