TouchDraw Code Reuse

​At the beginning of the year Frank Krueger posted a blog entry on the code reuse in iCircuit, which is built using MonoTouch and MonoMac.

As we're 1 or 2 days away from ​submitting TouchDraw for Mac to Apple, I thought it would be an interesting exercise to generate some statistics on the code reuse for TouchDraw.  Like iCircuit, TouchDraw for iPad is developed using MonoTouch, and TouchDraw for Mac is developed using MonoMac.

I used the same script that Frank created ​to calculate the stats, and I'll mention the same description/disclaimer that he did:  All the compiled code for each project is put into two buckets: unique code and shared code. Unique code is code used only for that project while shared code is code that was used in more than 1 project.

First, some pretty pictures:

​Code reuse between TouchDraw for iPad and TouchDraw for Mac

​Second, the raw output from the script is as follows:

app     t       u       s       u%      s%
iOS     139809	55685	84124	39.83 %	60.17 %
Mac     115221	29198	86023	25.34 %	74.66 %

t is Total lines of code
​u is Unique (platform specific) lines of code
​s in Shared lines of code.

​Lines of code include comments and white space.

Note: Like with iCircuit, we have a consistent coding style, so this simple metric is good enough for me to understand the relationship of our shared code to platform specific code.

As you can see, more platform specific code was required for the iPad version than for the Mac version.  There are many reasons for this; however our belief is that by the time we finish TouchDraw for iPad 2.0 and TouchDraw for Android (which is of course being built with Mono for Android) that the code reuse in the iPad version will increase to 65% to 70%.

Final Note:​ If you look really closely, you'll see that the "shared" lines of code above do not  match up. That is because when we calculate the statistics we are also measuring the  development version of TouchDraw for Android.  Once we get closer to the actual release of that, I'll share those numbers here as well.