locked
Silverlight, Astoria and domain objects RRS feed

  • Question

  • Hi, I have some questions regarding how to architecture Silverlight 2 applications using Astoria.

     

    1.       Are there any recommendations about placing business logic in partial classes for the Astroria “proxy-objects”. If you do this, these objects may become the real domain objects of the system and the Entity Framework would be treated more as a plain data store.

    2.       To avoid duplicating business logic, can you then use the same Astoria objects on the server, and is it possible to improve performance by not going through http when you are running on the same machine.

    3.       Are there currently any way to control the mapping of Astoria objects, if not, are there any plans of adding this. This could create a sort of “object-to-entity” mapper, improving the one-to-one mapping in the current Entity framework.

     

    Regards

    Henrik

     

    Saturday, March 1, 2008 6:42 PM

Answers

  • 1.       Are there any recommendations about placing business logic in partial classes for the Astroria “proxy-objects”. If you do this, these objects may become the real domain objects of the system and the Entity Framework would be treated more as a plain data store.

     

    >>> Typically your service tier will take a "dont trust the client" approach (as clients other than your own may be sending requests) and you'll appropriate logic on the server to ensure user input is appropriately sanitized and correct auth policies & business rules applied.  That said, there is definately a place for client side validation in AJAX/SL apps to reduce a roundtrip for simple validation.  So, IMO you will end up applying business logic (validation, etc) at the client and service tier as appropriate.  We're working on richer public content in this space now that the product is taking shape... 

     

    2.       To avoid duplicating business logic, can you then use the same Astoria objects on the server, and is it possible to improve performance by not going through http when you are running on the same machine.

    >>>> no, objects gen'd using our client code generator cannot replace EF generated objects on the server tier.  That said, one approach I've seen is to factor the app logic (validation, process, etc) into a component which is not directly coupled to a particular type... 

    >>>> we are looking into a better local story, but this isnt a V1 target for the product 

     

    3.       Are there currently any way to control the mapping of Astoria objects, if not, are there any plans of adding this. This could create a sort of “object-to-entity” mapper, improving the one-to-one mapping in the current Entity framework.

    >>>> in an upcoming drop of the library, you can hook up to a few new events (ResolveName, ResolveType, and a few more) that let you control the deserialization strategy to provide a looser coupling of types on the client to those exposed by the server.  These will be in the next drop of the client lib...

     

    Also, note the EF enables more than 1-1 mapping. Here is a brief writeup of their approach: http://blogs.msdn.com/esql/archive/2007/12/14/EntityFramework_5F00_ORM.aspx

    Friday, March 7, 2008 2:43 AM