R – Sharing code between compact and full .NET Framework

compact-frameworknet

I have a whole bunch of projects which I want to reuse between the .net compact framework and the full framework. I have read Daniel Moth's incredibly informative article about this subject (http://msdn.microsoft.com/en-us/magazine/cc163387.aspx)

So the two main methods are:

1) Target the compact framework (ie. go for the lowest common denominator)

2) Have different projects, linking to this same source.

I would prefer to go with method 1 simply because I would like to write ONCE, build ONCE and deploy ONCE. Are there any performance/memory/stability issues by going with this approach?

Best Answer

The first option sounds great in theory, until you're working on one of your projects, and you'd really like to implement some feature for the full version, but you can't for the compact version because it doesn't support it.

I would suggest trying to separate out all the "lowest common denominator" code into separate assemblies from everything else. If you handle your separation of concerns correctly you can have a front end for your full and compact projects by tying together the appropriate assemblies into each respective front end.

However, I think it's probably good advice to start by targeting the compact framework. Employ separation of concerns where appropriate, and when you get to a point where you really want an extra feature on the full version, then it's time to branch into two front ends. Don't do it until you need it, though, otherwise YAGNI.