views:

320

answers:

1

Hello everybody,

It's my first question on SO. I know that there were many topics on Silverlight and architecture but didn't find answers that satisfies me. I'm ASP.NET MVC developer and are used to work on architectures built with the best practices (loose coupling with DI, etc.)

Now I'm faced to the new Silverlight 4 project and would like to be sure I'm doing the best choices as I'm not experienced. Main features required by the applications are as follows :

  • use existing SQL Server Database but with possibility to move to the cloud.
  • using EF4 for the data acess with SQL Server.
  • exitensibility : adding new modules without changing the main host.
  • loose coupling.

I was looking at different webcasts (Taulty, etc.), blogs about Silverlight and came up with the following architecture.

  • EF 4 for data access (as specified with the requirements)
  • WCF RIA Services for mid-tiers controling access to data for queries and enabling end-to-end support for data validation, authentication and roles.
  • MEF Support for enabling modules.
  • Unity 2.0 for DI.

The problem is that I don't know how to define a reliable architecture where all these elements play well together. Should I use a framework instead like Prism or Caliburn? But for now I'm not sure what scenarios they support.

What's the best usages for Unity in Silverlight ? I used to use IoC in ASP.NET MVC for loos coupling and other things like interception for audit logging. It seems that for Silverlight Unity doesn't support Interception. I would like to use it to enable loose coupling and to enable to move to the cloud if needed.

Thanks in advance for your help.

+2  A: 

Best practice in Silverlight is actually (IMO) a bit a myth. By definition "Best Practice" refers to practices that generate the best results overall (quick to market, fast iteration of versions, low bug count, etc). However Silverlight 4 isn't even in production yet so its not actually possible to pin point what ultimately has turned out to be "Best Practice.

On top of that Silverlight itself and the technologies that surround it have been very fluid and and are very new. With that in mind here is my 2 pence.

EF and WCF RIA Services are most definitely going to figure in your architecture if you are build a LOB app. (Although NHibernate instead of EF may be worth a look, I tend to bias to MS components unless there is something else that knocks it out of the park).

MEF is most definitely worth further investigation if you are into DI. Its this area which is most in flux right now. I wouldn't be surprised to see Unity and Prism evolve to make greater use of MEF to deliver their various patterns. MEF is particularly good the loose coupling of which you speak.

AnthonyWJones
Thanks for your response. Since I asked that question I've been adviced by some SL developer and it's what he said:1. I should avoid Prism with SL4 as there is no added value for now. I should implement MVVM pattern myself.2. I should consider to use Unity for DI with ViewModels and for DataServices.3. MEF only when really needed because there could be some friction with Unity4. EF4 will be good for both Azure SQL, and stand alone SQL Server, but for Azure table Storage I should implement another DAL.5. Don't need to bother with POCO.What's your thoughts about that ?
@doteneter: I would pretty much agree with that assessment, However I still think you should examine MEF closely. I can well imagine there being some friction between Unity and MEF since there is some overlap there. However I really think that this will be sorted out in time and that you need to be careful you don't look back in 6 months wishing you'd intergrated MEF in your project from the Get-go. Its actually quite a tough time to start a project with so many things still being so fluid.
AnthonyWJones
Thanks for your help.