Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compact Framework - Is there an MVC framework/library available?

I've found an article on this subject by a Microsoft employee, but has anyone implemented a more robust framework for this? Is there a lightweight framework for WinForms that could be ported easily? I'd like to get up to speed fairly quickly and avoid producing a framework/library of my own to handle this when someone smarter has already done this.

I haven't looked at the Mobile Software Factory from the P&P group, but I suspect it's kind of heavy. Is it worth a look?

Edit: I'm not looking for information on the ASP.NET MVC project. I'm asking about the compact framework 'WinForms' implementation, and how to implement MVC with that.

like image 428
Brian Lyttle Avatar asked Aug 25 '08 16:08

Brian Lyttle


3 Answers

I personally think that the Mobile Software Factory doesn't hold much joy for CF. We still use one part of it (EventBroker) at work and I'd like to even remove that part if possible (as it doesn't support generic events and you have to cast the arguments into their strong types from EventArgs). A sister project at work used it for part of their UI but had to rip it out due to performance issues (another big project, although that has additional performance issues of it's own as well).

The issue I find with the MVP framework that the P&P lib offers is that Forms and Controls OWN presenters instead of Presenters/Controllers owning Forms (who didn't read "It's just a view" : Pragmatic Programmer?). This fits beautifully with MS's "Form First" rapid application development mantra but it sucks when you consider how expensive windows handles can be in CE (if you have a lot of them). We run a very large CF application at work and we've rolled our own MVC framework. It's not hard to roll your own, just make sure you separate everything out into Controllers, Views, Business Objects and Services and have a UIController that controls the interactions between the controllers.

We actually go one step further and re-use forms/controls by using a Controller->View->Layout pattern. The controller is the same as usual, the view is the object that customises a layout into a particular view and the layout is the actual UserControl. We then swap these in and out of a single Form. This reduces the amount of Windows Controls we use dramatically. This + initialising all of the forms on start-up means that we eradicate the noticable pause that you get when creating new Windows Controls "on-demand".

Obviously it only really pays to do this kind of thing if you are rolling a large application. We have roughly 20 + different types of View which use in total about 7 different layouts. This hurts our initialisation routine (as we load the forms at start up) by a magnitude of about 10 seconds but psychologically most users are willing to accept such a hit at start up as opposed to noticeable pauses during run-time.

The main issue with the P&P library in my books is that it is a FF -> CF port and due to certain incompatability and performance differences between the two platforms you lose a lot of useful functionality.

Btw, this is by far and away the most comprehensive article i've ever read on MVC/MVP. For Windows application (desktop or CE) I'd recommend using the Taligent Model-View-Presenter version without the interactions, commands and selections (e.g the controller/presenter performs all the work).

like image 98
Quibblesome Avatar answered Oct 21 '22 04:10

Quibblesome


Neither of you (davidg or Kevin Pang) paid attention to the fact that he's interested in WinForms, not Web Forms. He wants a framework that pushes the Model-View-Controller design pattern (davidg, MVC isn't just the name of an ASP.NET framework) in a WinForms project using the .NET Compact Framework. He asked his question just fine.

like image 31
Brian Warshaw Avatar answered Oct 21 '22 03:10

Brian Warshaw


There's also the OpenNETCF IoC framework (which I don't think existed when this question was asked) which is much lighter, but similar in object model to the P&P's Mobile Software Factory.

like image 34
ctacke Avatar answered Oct 21 '22 03:10

ctacke