NetMF has assemblies for the framework code (and GHI extensions). It also has namespaces to allow keeping collisions to a minimum. I have (over the last few years) developed some potentially reusable components. I use Interfaces to draw a clear line across the responsibilities of each component and that has worked well. The problem with including assemblies is keeping track of which version I have included with a particular program and the pain that occurs when the NetMF version changes. I learned about the technique of including a project from a different folder/solution and that seems to work pretty well during the debugging phase (which seems to never end, since NetMF keeps moving). To put this into a concrete example, I have a component that displays text (ITextDisplay). It has a very simple interface that I can use from other components. It originated from something for the Nokia5110 display and I generalized it years ago and adapted it to work with the display on the CANXtra and then the N18. Since it appears that Gadgeteer is on the way out, I have been reworking it to work without that requirement and work with generic SPI displays based on the ILI controller. So, I now have:
public interface ITextDisplay
public interface IBitmapDisplay
public class TextBitmapDisplay : ITextDisplay
public class IliBitmapDisplay : IBitmapDisplay
static IliBitmapDisplay Display = new IliBitmapDisplay(isLandscape: false,
width: 128, height: 160);
static TextBitmapDisplay TextDisplay = new TextBitmapDisplay(Display, SmallFont, BigFont);
TextDisplay.Print("Qylpe 10°F " + System.DateTime.Now.ToString("HH:mm:ss"), Colors.Red);
How would you structure the projects/solutions and why?
Right now, I have 5 projects (which seems a bit excessive, but does work). Since ITextDisplay and IBitmapDisplay are somewhat related, they could and probably should be in the same project/folder/solution. The two implementations are related in that one needs to use the other, so they probably could be separate, but from wanting to minimize the number of assemblies putting them together might make sense. The 5th project is the example program that demonstrates how everything works.