Geeks With Blogs
John Conwell: aka Turbo Research in the visual exploration of data

Recently I found a tool that will parse a .Net assembly(s) and return back an object graph of the underlying structure: Assemblies, Namespaces, Types, Members...all the way down to the IL opcodes in each method.

This opens a lot of doors to writing tools that can look at the overall architecture of your application, across many assemblies.  One tool I wrote creates a MD5 hash of the contents of each method, based on the IL opcodes and the values they are operating on.  From this I can then figure out which functions are exact duplicates of other functions in your code (Steven Mcconnell once said that copy/pasted code is a design flaw).

So I ran the tool on one of my applications and came up with a lot of duplicate functions.  But after looking at them I realized almost all were one line property getters, that were returning a private field.  The other culprit was default constructors that get generated for you by the compiler if you don't have one, or if you have an empty one.  Once I weeded these culprits out of the analysis, I came up with very few duplicated functions.

Then, just for fun, I sicked my tool on Microsoft's System.dll to see how original their programmers were.  Turned out i found 88 duplicate functions.  That means there were 176 functions that shared code with another function.

Posted on Thursday, November 3, 2005 10:28 AM | Back to top

Comments on this post: How unique is your code?

# re: How unique is your code?
Requesting Gravatar...
Can you please post your code and link to the tool you are using
Left by Manolo on Nov 04, 2005 4:36 AM

# re: How unique is your code?
Requesting Gravatar...
nice to hear news from u dude!
Left by mp3 on Mar 23, 2006 1:10 AM

Your comment:
 (will show your gravatar)

Copyright © John Conwell | Powered by: