Clone Detective

I read an InfoWorld article by Paul Krill entitled “Cloned Code Finder Offered For Visual Studio”. It announced a web based product from Microsoft called the Clone Detective. This is a tool that works with Visual Studio. If analyzes C# source code, and locates duplicate code. It has been released under the Apache 2.0 license. That means the software is free to use. It also means that you can use it in other open source projects as well as in proprietary projects.

There is a plan to release future Clone Detective versions that work with other popular languages such as C++ and Visual Basic. There is also a plan to add “fuzzy clone detection” to the tool in the future. This will allow you to locate code that is not an exact cut and paste, but close to it.

It is too bad that this product only analyzes C# right now. Almost all the code on my current project is written in C++. It is a huge legacy project around 15 years old. Some of the code was well thought out and designed well. However there are a lot of places where changes were hacked in. So I know we have a load of code that was cut and pasted. It would be nice to refactor a lot of that code to make a cleaner code base. It is possible to do this manually. However it would be nice to use a tool to analyze the code and at least find the places where we have duplicate code.

I might write up some dummy projects using C# just to give Clone Detective a spin. Of course I will use poor practices while coding up this sample app. And I will cut and paste galore. However I will make a few changes in the code copies and see how well the detective can, well, detect.

StyleCop

Microsoft has released StyleCop 4.3 to the developers. StyleCop is a source code analysis tool for the C# programming language. It has been used at Microsoft internally for many years. The tool enforces the best practices in source code. It is similar to another tool from Microsoft called FxCop. However StyleCop works on source code, while FxCop works on binary files.

StyleCop does not focus on the design of code. Instead it focuses on the layout, readability, and documentation in the code. The overall goal is to produce code that others can easily read. The rules which the tool enforces cannot be easily configured. The tool implements around 200 best practices in the code. Some of these are location of brackets, spacing, ordering of elements, and variable naming. The tool can be run within the Visual Studio IDE. It can also be integrated with builds.

There was a lot of interesting feedback to the release of StyleCop. Many people including myself were interested in a tool like this for other programming languages. There is also a great desire to disable and configure the rules enforced by the tool. Users have commented that some of the rules are just plain silly. The VS Law program performs a similar function for Visual Basic code. Some developers worried that this tool would be used by control freaks for evil purposes.

Unfortunately we code almost exclusively in C++ on my current project. So StyleCop would not be of much use. However we try to cover best practices when doing peer reviews. It would be nice it we could delegate that task to a tool such as StyleCop. Come on Microsoft. Hook us up.

Visual Studio Uninstall

A system administrator cloned a development machine for me, and provided me with a virtual machine to use for development. I got some code that I needed to change. Then I figured up Visual Studio 2005. The C++ compiler immediately complained that I needed to repair the Visual Studio installation. So I got the install media and attempted a repair. The repair warned that I might not have enough disk space for the install. Then it kept requiring a reboot. However when I rebooted the install did not pick back up. I went through the repair a couple more times until I gave up.

At this point I decided to uninstall Visual Studio 2005 and try again. So I used Windows Add/Remove programs. I selected Visual Studio 2005 and chose to remove it. This removal took quite a long time. At the end of the install I got a horrible warning message. Microsoft wanted me to manually go in, find out if any listed components were present on my system, then remove them one at a time. What the heck is this? The install program was smart enough to know what items to install. Can’t it also uninstall them without me prodding it for every component? Bad form Microsoft.

Just so you don’t think I am overreacting, take a look at the warning message for yourself:

Next Step: Uninstall additional components

Additional components might have been installed on your computer by Visual Studio during setup.
These components must be manually uninstalled using Add or Remove Programs in the order listed below.

Note: Uninstalling these components might affect other applications you have installed that rely on these components.

The following components might have been installed with Visual Studio:

Microsoft MSDN 2005 Express Edition
Microsoft Visual Studio 2005 Tools for Office Runtime Language Pack
Microsoft Visual Studio 2005 Tools for Office Runtime
Microsoft Device Emulator version 1.0
Microsoft .NET Compact Framework 1.0
Microsoft .NET Compact Framework 2.0
Microsoft SQL Mobile 2005 Development Tools
Microsoft Visual J# 2.0 Redistributable Package
Microsoft Visual J# 2.0 Redistributable Language Pack
Microsoft Document Explorer 2005
Microsoft Document Explorer 2005 Language Pack
Microsoft Data Access Components 2.8 SP1 (Windows 2000 only)
The following components might have been installed with SQL Server Express, and need to be removed in the order listed below:
Note: Uninstall of the SQL Express instances will leave behind the user-created databases, which can then be re-attached to the new instance.

Microsoft SQL Server 2005 Express CTP
Microsoft SQL Server 2005 Express Tools CTP
Microsoft SQL Server Setup Support Files
Microsoft SQL Native Client
The following components must be uninstalled last:


MSXML 6.0 Parser and SDK (only on 32bit)
MSXML 6.0 Parser and SDK x64 (Only on 64bit)
Microsoft .NET Framework 2.0 Language Pack
Microsoft .NET Framework 2.0

Midori Operating System

I recently read an article online at Software Development Times. It was about a new operating system from Microsoft called Midori. The unusual thing about this operating system is that it is not a new version of Windows. It is instead based upon another research operating system from Microsoft called Singularity. Midori is meant to coexist with old Windows applications. However it does get rid of dynamic link libraries. It also builds Service Oriented Architecture into the runtime. The API is object oriented. Application created for the new operating system will be written in .NET languages. This project falls under the Microsoft Research division.

Since the Midori Operating System is based on Singularity, I thought I would mention a bit about it. Singularity is another operating system from Microsoft Research that was released in 2007. It is a microkernel operating system. It has some unique characteristics. Applications run in one process (address space). The kernel, device drivers, and application are all written in managed code. The goal is for the operating system to be highly dependable. Low level interrupt code is written in a combination of assembly and C programming languages. The hardware abstraction layer (HAL) is written in C++.

The Midori Operating System is being written with the Bartok compiler. The Bartok compiler is yet another project out of Microsoft Research. It is intended for writing efficient code needed to write operating systems. The compiler itself is written in C#. This compiler was also used to write a lot of the Singularity operating system. This operating system allows an application running in it to choose a version of components (such as garbage collection) at run time.

Obviously there are some very interesting projects coming out of Microsoft Research. I wonder if any of these will reach a production status on par with something like Microsoft Visual Studio.

Help Compiler

Recently our team has migrated from Visual Studio 6 to Visual Studio 2005. This was a long overdue upgrade. We skipped over some intermediate versions of the tool. And I think it made our migration more difficult. Most of our applications are old and have no built in help systems. However one recent application has a pretty good contextual help system. The developer tasked with migrating that application complained that the compilation for the help bombed immediately.

After a bit of research, the developer found that Visual Studio 2005 does not by default install the Microsoft Help Compiler. This seemed very strange. What was Microsoft thinking? They do provide a freely downloadable help compiler. Maybe developers no longer ship help with their applications. Or maybe they use other tools like RoboHelp from Adobe. I don’t know.

I believe Microsoft ships its Visual Studio 2005 on DVD. There should be plenty of room on that DVD for the Help Compiler. Not including it has made our life a bit more complicated. It is no big deal for developers to download and install the help compiler. But things get tricky for other individuals. Our configuration management team normally does our builds. They did not know how or where to install the Help Compiler.

To tell the truth, I have not even installed the Help Compiler on my machine. I guess I will not be building that application locally any time soon. Before completing this post I decided to browse the web to find out why Microsoft chose not to include the Help Compiler with Visual Studio. I think I quickly found out the answer. Microsoft’s new solution for help is HTML Help. Perhaps the old Help Compiler (which Microsoft calls the WinHelp Compiler) is going out of style.

My hope is that Microsoft does not leave us stranded having developed an extensive WinHelp component to one of our applications. Why convert to a new HTML Help system when it will not improve our end user experience any? Knowing Microsoft, I had better brush up on the new HTML Help system to be safe.

Microsoft Marketing

I recently read a blog post making fun of a Visual Studio advertisement by Microsoft. This interested me because I had seen the ad in a magazine before and thought it was funny. The ad features before and after pictures of a developer who has started using Visual Studio. Apparently Visual Studio has enabled the developer to get a better laptop, a BMW to drive, and the attention of some attractive females in his cubicle.

The blog post is from . This is a blog about open source software. So you know it was going to razz Microsoft. Essentially the author modified the ad, and pointed out the humor that ensues. It was nice to see that there were 30 responses to the blog entry. And I wanted to add my 2 cents. Unfortunately I got the following automated reply when I tried to add a response”:

“Sorry, but your comment has been flagged by the spam filter running on this blog: this might be an error, in which case all apologies. Your comment will be presented to the blog admin who will be able to restore it immediately.
You may want to contact the blog admin via e-mail to notify him.”

Now I am hoping that a human will review my response. It was actually a meaningful reply that was not spammy in the least. A human should be able to detect this. My first thought about being rejected by spam filter was maybe due to the fact that I have black hat in my e-mail address. Then I started thing some more. I am a Microsoft developer. In other words I am pro-Microsoft. Maybe the blog author has written a really smart spam filter that blocks out posts that are not pro-open source.

To quickly determine whether my e-mail address was the problem, I submitted the same response to the blog post using another email address. This time I made sure there was no reference to “black hat” in my e-mail or home page URL. I still got the same automated response from the blog. Who knows? Maybe all responses must get approved by the blog author. Well just for that I am not linking to his blog from this post.

New Windows

Bill Gates recently came out and said the next version of Windows will be released in about a year. That version will be called Windows 7. I hope it will get a warmer welcome than Vista. Somehow to me it seems that Microsoft is a bit off in its numbering. Here is how I figure we should be up to Windows 8 by then:

3.1 Windows for Workgroups
4.0 Windows 95
5.0 Windows NT
6.0 Windows XP
7.0 Windows Vista
8.0 (the next Windows?)

Perhaps Microsoft has a different numbering strategy. Maybe Windows 95 and NT both count for one generation of Windows. Or maybe Windows NT does not count in the grand order of home windows operating systems.

I bet that, by the time the next version comes out, it will have a sexier name than Windows 7. Who knows? I could come up with a snazzy name myself and submit it to Microsoft for consideration. All I would want are bragging rights, and maybe a link from the Microsoft web site to my little blog. Not too much to ask for if I do say so myself.