views:

33

answers:

3

I need to build an application in C# that will have multiple UIs, 2 for web and one that will be the same application, but able to be used with no internet access. I am leaning towards MVC for web, then MVVM/WPF for the windows application (Silverlight is not an option). I should be able to inject a different repository implementation for the two paradigms, thus solving the disconnected-from-the-internet issue.

What I am wondering is how best to re-use as much presentation logic as possible. Ideally, I would like to be able to use the same controller/presenter-type entities to run both UIs. I'm looking for an example of a good solution to this problem. I don't see a clear path to re-using MVC's Controllers (they seem too tighly bound to the MVC framework to work), but at the same time I'm not excited about the overhead involved in implementing a custom MVVM or MVP pattern for the web (which I fear is the answer).

Alternatively, am I crazy to even try to re-use those components? Is it not worth the hassle? We can easily share the services underpinning the UIs, but it seems a shame to write such similar UI code twice.

A: 

You have the option of using WPF for everything for max re-use. WPF can be deployed as partial trust XBAPs.

There are downsides though * Download size can be a problem * Clients need the correct framework version and can only run in Internet Explorer (Firefox through plugin (not working on Windows 7))

I've tried it on a solution with a small XBAP client and a larger Standalone Application - and it is really minor details that cannot be reused (Window in app, Page in XBAP and so on). Makes for nice consistent layout too.

Goblin
Unfortunately, the web applications need to be widely available and easily accessible (meaning we have to build them to the least common denominator; a simple html website)
Anthony
+1  A: 

The right thing to do is to share only the Business Layer and Database Access Layer. At least you will have consistency between all the clients.

Then build the clients taking advantage of the benefits of each platform (richness of the desktop app and simplicity in the web app)

Of course it all depends on the budget.

Eduardo Molteni
Yes, we will definitely be sharing those. This is probably where I will end up, but I was hoping to share some UI logic, too.
Anthony
A: 

This is slightly hackish (and not really recommended, unless you really understand what you are doing :)), but you could try creating a desktop app, which embeds a browser. This enables you to reuse the GUI. You will also need to package a web-server, which might be a problem though if you are using C#/MVC/.NET.

tathagata
You wouldn't even have to make that a windows app, in that case--we could just make it a local website. We've discussed that, but the embedded web server is what stopped is thinking along those lines.
Anthony