views:

173

answers:

4

I've been given the ask of converting an MVP ASP.NET app to Silverlight. This will be my first Silverlight application and I'm struggling to determine how best to organise the architecture.

The app is very much a standard CRUD LOB app. I will also be using a GIS component but I dont think this makes a difference to the general architecture (please correct me if it does). I'll be using Subsonic as the DAL, but again I dont think this makes a difference to my architecture.

The original application is rather large, so if possible I would like to reuse as much of the model and the view as possible.

Reading around on the web its a little confusing as to what is considered 'best practices' for the architecture of Silverlight 3 LOB apps. Microsoft seems to be pushing this RIA framework - but its only in preview...is it production ready? I get the impression that Microsoft are pushing different architectural guidelines with Silverlight 3, but I'm struggling to find out what exactly these architectures are!

There is also Prism, and the Caliburn project.

Luckliy I have a very flexible deadline here, so I'd like to get as close to best practices even if it means a bit of a learning curve at the beginning.

I would greatly appreciate a friendly nudge in the right direction.

edit in response to answers so far

  • The solution will be a 100% fullscreen Silverlight app. I am not interested in a mixed Silverlight-Asp.net frontend.

  • With this in mind - I want to maximise the reuse of the model and view part of the codebase, but only if this is possible without making major sacrifices to the new architecture.

  • The solution needs to come from Microsoft or at least be very well supported.

  • If RIA is liable to change before release, its totally out of contention.

second edit

Thanks everyone for their excellent answers. I've upvoted everyone but the answer has to go to Steve because his answer was actually the series of questions I should have been asking myself.

I'll update the thread once I've had a good look at both Prism and CSLA.

I love you all.

+1  A: 

You might want to take a look at the CSLA framework, while it's not for everyone, it is a nice, easy to use and powerful framework.

The author, Rockford Lhotka, also wrote a version just for Silverlight and provides a video series on how to create applications using CSLA and Silverlight, to help developers get up to speed quickly.

Some links for you to check out:

mattruma
ooh CSLA yes that is another way to go !
76mel
@mattruma - can you be more specific? Why is not for everyone? Why should I consider it over the Prism/MVVM model, taking into account I've modified my question a little to clarify the requirements.
Alex
It's not very friendly when it comes to a testable framework ... mock up objects and so on. That's about the harshest criticism it gets, other that, I love it ... I have used the Windows/Web CSLA framework for 6+ years.
mattruma
@mattruma: Ok, so assuming I can live with the weak testing, why *should* I be choosing CSLA. What will it do for me over Prism?
Alex
I'm not familiar with Prism ... but I would search the CSLA forums ... here is a link http://forums.lhotka.net/forums/thread/33469.aspx, here is an example of project using Prism and CSLA http://www.codingandcoffee.com/Blog/archive/2008/12/17/3.aspx.
mattruma
+1  A: 

I personaly would vote for prism for a sizable app, RIA does have "go live" licence but i would trust that just yet. Remeber that you can mix and match.

Check out http://compositewpf.codeplex.com/

and http://www.sparklingclient.com/prism-silverlight/

76mel
+2  A: 

So many options :-) Your choice probably depends on several factors:

  • How much you want to reuse of the current solution
  • Whether you want a full screen SL app, or just replace parts of the site with "richer" content
  • How your current app is structured, both visually and what your ActionMethods are returning
  • Timescales

RIA services might be a decent fit, as it would allow you to at least reuse your model and validation (if you're using data annotations) but it's some way off and likely to change before release.

The other option is a ground up Silverlight app, for which I'd recommend taking a look at PRISM and MVVM for structuring it (if only to keep the initial payload down!). You could probably reuse your model, and there is support for data annotations in Silverlight, but you wouldn't be far off recreating a new application.

The third option, and one that you may love or hate, would be to build "islands" of rich functionality in SL for areas of your site. You could use your existing MVC app and potentially have ActionMethods return JSON (or XML if you'd prefer) which your SL areas could consume and render. You'd have decent code re-use and you could enhance areas of the site in isolation.

An open ended answer to an open ended question :-)

EDIT: Judging by your responses, if it were me, I'd be creating a PRISM app. If it's currently a web app it should "sit" quite well with the region model (although you wouldn't be actually reusing any view code), and the dynamic XAP loading will help with your initial payload if you want a single full screen app. If it's a CRUD based app then you might want to take a look at the XAML Power Toys to quickly put data forms together.

Datawise you could either reuse your model and expose it via WCF or ADO.Net Data Services, wait for RIA services to stabilise (depending on your timescales) or still use the MVC action methods but return JSON from them for the SL app to consume.

Steven Robbins
Quality answer! And yes, I am being too open ended. I shall edit my question to include some of the answers to your questions.
Alex
Well there is no *right* answer, but hopefully I've given you some food for thought to make a decision :-)
Steven Robbins
@Steve: What do you mean by Timescales?
Alex
That was more of a question to do with RIA services i.e. whether you can afford to wait for it or not.
Steven Robbins
I've updated my answer to reflect the updated question.
Steven Robbins
+1  A: 

We've been going for a couple months now. We're using Prism and RIA services. I think that there is a bit of a learning curve, but I enjoy Prism and there is some support for it online.

RIA services is a bit more iffy, but I think it's worth using. We started trying to use it soon after the July Preview, and there wasn't much documentation online to look at. as these past few months have gone by, we've managed to make it do what we want, and there are more examples and solutions online that help. Microsoft is pushing it, and I think that they'll come through in the end.

thepaulpage