Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Design Patterns that work in .NETMF


  • Please log in to reply
11 replies to this topic

#1 H07R0D

H07R0D

    Advanced Member

  • Members
  • PipPipPip
  • 95 posts

Posted 28 March 2011 - 07:03 PM

This is my first step into Micro. We're building a Reef Aquarium, and I figured I would roll my own controller system instead of spending many hundreds for an OTS solution.

I'm curious about what I can expect from code on the Netduino. Specifically, I'm wondering about what design patterns would play well in this environment.
Currently I'm leaning towards these:
I like Plugins since I'll be adding bits and pieces as I go along (i.e. temp probe, ph meter, solenoid control) so a solid scaffold would be nice. I like MVC because I'm hoping to have multiple input/output options (Web/LCD Shield) for common data.

Am I nuts to head this route in the .NETMF? I'd love to find some good reading on strengths and weaknesses of the .NETFM

Thoughts and comments greatly appreciated.

#2 Corey Kosak

Corey Kosak

    Advanced Member

  • Members
  • PipPipPip
  • 276 posts
  • LocationHoboken, NJ

Posted 28 March 2011 - 09:34 PM

Am I nuts to head this route in the .NETMF? I'd love to find some good reading on strengths and weaknesses of the .NETFM

I think it is ideal for this. The version of C# supported on the Netduino is easily rich enough to support all of the well-known design patterns. Regarding strengths and weaknesses, in a nutshell I think of them as
  • No generics
  • Much smaller libraries (so your favorite library routine might be missing)
  • Limited memory (so you need to watch out if you're writing a large program)
  • Interpreted .NET rather than compiled (your program will be much slower than it would be on your PC)


#3 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 29 March 2011 - 03:50 AM

Your question is the same I have posted myself a couple of months ago. Corey already pointed out some highlight, but there is something else too... The very limited ram available forces you to avoid some patterns in favor of others. Consider the speed of execution about 1000x a normal pc. Sometimes is faster, but could be also slower: depends on the section we are talking for. The xml support is very limited. For the web front-end, I'd suggest a Silverlight application, which is very rich and requires a few support from the server side. Anyway, if you are going to build an aquarium controller, I agree with Corey that a Netduino device would be a good choice. Instead, if you are going to create a modular PLC-like device, I guess you'll have hard-time. Cheers
Biggest fault of Netduino? It runs by electricity.

#4 demonGeek

demonGeek

    Advanced Member

  • Members
  • PipPipPip
  • 42 posts
  • LocationCanada

Posted 29 March 2011 - 04:01 AM

Am I nuts to head this route in the .NETMF? I'd love to find some good reading on strengths and weaknesses of the .NETFM

There's nothing wrong with using design patterns but I would caution that you should be very aware of the memory restrictions imposed by this type of platform.

I have used MVC to great effect in regular Windows GUI apps, it really makes the code manageable but then I'm not particularly worried about the size of the executable in that environment.

If the framework brings a lot of extra overhead - either in processing time or memory footprint - you will notice it a lot sooner on the Netduino and then you may be forced to decide between form and function.

Also, as Corey mentioned, some of the things that can make a design pattern a joy to use are missing from NETMF - generics is a good example.

- Adam

#5 demonGeek

demonGeek

    Advanced Member

  • Members
  • PipPipPip
  • 42 posts
  • LocationCanada

Posted 29 March 2011 - 05:07 AM

Just came across this post by JonnyBoats which is relevant to the discussion.

If the Micro Framework GC works in the same way as the Compact Framework (only one-generation GC), then your choice of design pattern may well have an impact on the GC and therefore overall performance of the application. Something like MVC with long-term objects may not provide the best performance.

Of course this is going to vary from one application to the next - if you're not pushing the processing/memory limits of the device then GC probably isn't going to be a big deal anyway. Just something else to consider ;-)

- Adam

#6 H07R0D

H07R0D

    Advanced Member

  • Members
  • PipPipPip
  • 95 posts

Posted 29 March 2011 - 11:56 AM

Thanks for all the great input. I think I'm going to like it here :) With the small amount of ram, I was thinking about building some quasi-caching routines for the MicroSD card. I'm definitely not looking for anything that needs to be very fast, as all the data collection and control execution can be rather lazy and won't affect the aquarium. I'm having second thoughts about the Plugins interfacing. How well does the device handle Reflection? That was my plan originally, but I know it can be expensive on a macro scale, so on a micro one it would probably be tough. I'll see how it goes. Now I just have to wait for canakit.com to ship my device.... Cheers,

#7 Corey Kosak

Corey Kosak

    Advanced Member

  • Members
  • PipPipPip
  • 276 posts
  • LocationHoboken, NJ

Posted 29 March 2011 - 12:22 PM

I'm having second thoughts about the Plugins interfacing. How well does the device handle Reflection?

I'm sort of surprised by the question. I assume that because you're trying to make your code all nice and structured, you'd prefer to implement the design patterns you're talking about with interfaces or delegates/lambdas. Why bother with reflection?

To answer your question, it has some of the full-framework Reflection API but several things are missing.

#8 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 29 March 2011 - 01:31 PM

Anyway by loading pieces of assembly from SD will eats even more ram. That would be useful and nice, but far from this kind of context.
Biggest fault of Netduino? It runs by electricity.

#9 H07R0D

H07R0D

    Advanced Member

  • Members
  • PipPipPip
  • 95 posts

Posted 29 March 2011 - 02:35 PM

I'm sort of surprised by the question. I assume that because you're trying to make your code all nice and structured, you'd prefer to implement the design patterns you're talking about with interfaces or delegates/lambdas. Why bother with reflection?

To answer your question, it has some of the full-framework Reflection API but several things are missing.


I was just thinking about dynamic plugin loading. My initial (rough) idea was to pull an available plugin listing, look for any marked 'active' and instantiate them at runtime. I'll take a look at the delegate route, as that really does make more sense.

#10 Dave White

Dave White

    New Member

  • Members
  • Pip
  • 2 posts
  • LocationMunich, DE

Posted 18 April 2011 - 10:51 AM

Now I just have to wait for canakit.com to ship my device....


Hi Corey, I'm curious to find out if you have recieved your unit yet. I purchased a Netbuino plus from Canakit back in February it was shipped to me after the restocking bin March. However, today I have received an import bill from UPS for almost as much as I paid for the unit, with the explanation that they had shipped it from Canada.

Did you have a similar experience? Has anyone else been hit with such a surprise when ordering from a European Website?

--Dave

#11 Corey Kosak

Corey Kosak

    Advanced Member

  • Members
  • PipPipPip
  • 276 posts
  • LocationHoboken, NJ

Posted 18 April 2011 - 08:51 PM

Hi Corey, I'm curious to find out if you have recieved your unit yet.

Hm? I'm guessing this question was directed at H07R0D rather than me.

#12 Dan Morphis

Dan Morphis

    Advanced Member

  • Members
  • PipPipPip
  • 188 posts

Posted 18 April 2011 - 09:50 PM

Hi Corey, I'm curious to find out if you have recieved your unit yet. I purchased a Netbuino plus from Canakit back in February it was shipped to me after the restocking bin March. However, today I have received an import bill from UPS for almost as much as I paid for the unit, with the explanation that they had shipped it from Canada.

Did you have a similar experience? Has anyone else been hit with such a surprise when ordering from a European Website?

--Dave


Dave, I ordered mine from Canakit as well. Mine was shipped via the postal service and I haven't been hit with any import duties (yet). Keep us posted on what goes on with this please. The outcome from this will effect where I order from in the future.

-dan




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.