Wednesday, July 7, 2010

On using NDepend

I was recently introduced to try out NDepend which is a Visual Studio add in and pretty much
a code metric and code quality tool to manage complex .net projects / solutions.

After a painless download and install I fired up visual studio 2008, loaded up my template project for a web application, did an analysis and was greeted with an html file with all kinds of reports.

at first it was a bit overwhelming but upon reading the report I was surprised at the information it had about my project.

One of the first things that got my attention was the "Assemblies Metrics", this pretty much tells me how abstract my assemblies are, lines of code, lines of comments, coupling and cohesion. just by having this and running it on every build or release would show how my project is growing and where it's headed.





Next is the Assemblies Abstractness Vs. Instability.
(explaining the chart is another topic altogether but for a primer this document explains it pretty well)

but the main point of the graph are

Abstraction where it would show how extendable your assembly or code is.

Stability where it would explain how dependent your code is to other assemblies or components, this doesn't mean that the

higher the instability the more unstable your code will be but rather how dependent your code is to other assemblies, (more dependent it is the harder it is to change your code.)

if the assembly is not that extensible the more it will go to the zone of pain (this would be pretty normal on end points like web services and wcf services, where it's usual that there would be no virtual methods or abstraction).

the zone of uselessness would show that if your class is too abstract and no other classes depends on it then it goes there.



Assemblies Dependencies Diagram I can't stress enough how many times this could have saved time on my previous projects where a visual diagram would show
class heirarchy and dependencies.








Running up Visual NDepend provides you with the CQL Queries (Code query language), this uses the same syntax as SQL but uses your code base as the database and right now the default code quality metrics NDepend has seems to cover everything I would need to be able to refactor my project properly.

things like Unused codes / dead codes, code quality, naming conventions and Encapsulation are queried, now other products also does this like resharper / FXCop but I like the extensibility NDepend offers. although I'm a bit half hearted on this one since I like how resharper presents the code errors and optimizations while I'm coding, NDepend seems to target more the team lead / architect level where code reviews are done and evaluated.


so far I've only been playing around with this tool for a couple of days and it is quite impressive, This is the kind of tool I would recommend to a company with large projects and solutions where managing source code becomes more and more "challenging" as it grows.

There's a Trial / Open Source / Academic Edition and you could buy the Professional Edition for about US$ 377, the more licenses the bigger the discount (although I'd assume you'd only need 1-2 licenses per project in a company.)

you could also check out their site for tutorials and videos about the product.

Saturday, July 3, 2010

Sharepoint 2010 problems for old MOSS developers?

My biggest problem with Sharepoint 2010 right now is it killed the standalone developer support that does not have a killer machine.

On MOSS 2007 I was used to running a VM network on my laptop (or dekstop server) with Moss 2007 on one VM, Domain server on another VM and my dev environment on a 3rd VM (sometimes this is reserved for an ISA server or Biztalk depending on the requirements).

This makes sure I could develop and debug my applications without being connected to a dev server, as well as making sure that if i ever screwed up my VM I could just plug in another one from my backups.

Sharepoint 2k10 now killed this concept with the requirements of having SQL Server 64bit and Windows 2008 Server r2 64bit.

since most mid range laptops are running on 32bit OS and VMWare / Virtual PC doesn't support CPU virtualization, I'll be stuck with SPS2k10 running on my dekstop and my dev environment running on my laptop for now.

you could also use this tool to check if your laptop could support 64 bit VM

for now... I'll postpone migrating my environments until I could properly backup my laptop and change it from Windows 7 32 bit to 64 bit (and download all the requirements which with the problems I'm getting from my ISP could probably take me 3 years to finish.)

I also wonder...how painful would it be to migrate my web parts, custom controls and Portal. Hope it's not as painful as migrating from 2003 to Moss :P