1 / 26

Developing with WCF RIA Services Quickly and Effectively

Developing with WCF RIA Services Quickly and Effectively. Nikhil Kothari Software Architect, Microsoft Corporation Blog: http://www.nikhilk.net Twitter: @ nikhilk. Agenda. Getting started on an application End-to-end introduction Going beyond the basics Implementing MVVM/ ViewModel

arlen
Download Presentation

Developing with WCF RIA Services Quickly and Effectively

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Developing with WCF RIA Services Quickly and Effectively Nikhil Kothari Software Architect, Microsoft Corporation Blog: http://www.nikhilk.net Twitter:@nikhilk

  2. Agenda • Getting started on an application • End-to-end introduction • Going beyond the basics • Implementing MVVM/ViewModel • Designing the application logic • Tips and guidelines along the way • Sneak peek at future possibilities

  3. The RIA Services Vision • Simplify n-tier data-driven application development • A higher level framework on top of existing building blocks • LINQ, Data Access Technologies, WCF, Metadata • Provide an application architecture that scales to fit needs of breadth line-of-business applications

  4. What would you like to see? • http://www.nikhilk.net/RIA-Services-MIX10.aspx • Pick a real-world scenario; skip the drag/drop • An example of when UI is not mapped one-to-one with a database table • An example of projections across tables • An example where DAL types are not passed to the client • An example of using a stored procedure • When to use [Invoke] vs. Insert/Update/Delete methods? • How to implement the combobox/lookup table scenario? • How to make RIA Services work with MVVM?

  5. An End-to-End Introduction to RIA Services Demo

  6. BookClub Application • DomainContext • Stateful view + Bindable Data • class BookShelfContext • EntitySet<Book> Books { get } • EntityQuery<Book> GetBooksQuery() • Entities • class Book • Data members + Validation • DomainService • Stateless CRUD + App Logic • class BookShelfService • IQueryable<Book> GetBooks() • void ShareBook(Book) • void UpdateBook(Book) • void UnshareBook (Book) • Validation, authorization, business rules • Data Model • class Book Data Model + Metadata + Shared Code Services Application Presentation Logic App Logic Data Access Layer Network DB var q = Context.GetBooksQuery() Context.Load(q); Context.Books.Add(newBook); Context.SubmitChanges(); DomainService.Query Invoke GetBooks() Compose query, execute, serialize results DomainService.SubmitChanges Authorize, Validate, Execute, Persist Queries and ChangeSets

  7. Thinking ViewModel aka MVVM • A pattern for separating application behavior out of the user interface • Motivation • Facilitate designer/developer workflow, and independent design/development activity • Encapsulate state and operations of application • Improve maintainability • Facilitate testability

  8. ViewModel + RIA Services Application Presentation XAML, UI Logic View Model App State, Operations, Notifications Data Model Services, Business Rules

  9. Sketching the ViewModel SaveBooks() LoadBooks() LoadMoreBooks() ShareBook() Books SelectedBook (two-way) SelectedBook EditBook() UnshareBook()

  10. Implementing the ViewModel Pattern with RIA Services Demo

  11. The Role of DomainServices • Encapsulate reusable application logic and expose it as a set of CRUD • Meaningful tasks unique to your application • Interesting implementation scenarios • Constraining results • Validation, authorization and business rules • Shaping data • Aggregating data • Caching • Triggering business processes • …

  12. Designing DomainServices - Identifying the Tasks GetBooks ShareBook UpdateBook UnshareBook

  13. Designing DomainServices -Identifying the Tasks GetLatestBooks GetBooksOfDay SearchBooks RequestBook

  14. Designing DomainServices – Presentation Model Types

  15. Layering your DomainServices DomainServices + Entities BookShelf Service BookClubService BookInfo Book IQueryable<BookInfo> GetBooks() void ShareBook() void UnshareBook() void UpdateBook() IQueryable<BookInfo> GetBooks() IQueryable<BookInfo> SearchBooks() IQueryable<BookInfo> GetBooksOfDay() void RequestBook(intbookID) ReferenceDataService Category IQueryable<Category> GetCategories() Data Access Layer + DAL Types Amazon BookClubObjectContext Book Request Checkout Category Member

  16. Walkthrough of an Interesting DomainService Implementation Demo

  17. Recap: Tips and Guidelines • Constrain your queries • Parameters, business rules, result limits • Define specific operations on your domain service that match your application semantics • Use validation to enforce rules, and provide useful user experience • Member, Entity, Operation, Server-only, Async • Use authorization to restrict access to data and operations • Handle errors – any Load/Submit could fail • Separate out reference data to facilitate sharing and optimal loading

  18. Recap: Some More Tips • Focus on the tasks that define your application • Customize your DomainServices • Group logically related tasks per DomainService • Create custom entity types designed for use between client and server when appropriate • Expose sufficient and minimum amount of information • Aggregate, re-shape, project on the server • Consider security, band-width and latency

  19. Scaling your DomainServices Databases ADO.NET, ORMs (LTS, EF, …) .NET Clients Silverlight, Phone, WPF Standards Clients JavaScript App Logic Lists/Objects Repository (NHibernate, …) Server Rendering HTML, Sitemaps Services REST/SOAP (Azure, …) Services SOAP, XML, JSON, OData Unit Test Code

  20. RIA Services + Windows Phone 7 Demo

  21. Related Talks • CL08 – Microsoft Silverlight 4 Business Applications • CL50 – Search Engine Optimization for Microsoft Silverlight • FT15 – Accessing Data in a Microsoft Connected Web Application • EX14 - Understanding the Model-View-ViewModel Pattern • RIA Services Meetup at 8pm today in 24001

  22. Roadmap and Further Information • Bits • Today: Feature-complete RC build that works with SL4 and VS2010 RC • V1: Ship with SL4 on top of .NET 4/VS2010 • Hosters starting to get on-board (eg. DiscountASP, OrcsWeb) • More Information • http://silverlight.net/riaservices - RIA Services Online • Blogs • http://www.nikhilk.net • http://blogs.msdn.com/brada • http://jeffhandley.com

  23. Call to Action • Get a jumpstart on your next Silverlight-based LOB/data-driven app • RIA Services builds on WCF and Silverlight 4 and provides end-to-end solutions • Takes care of services infrastructure, binding infrastructure • Implement well-architected manageable application, and work well for designer/developer workflow • RIA Services is complemented by patterns such as task-centric design approaches and ViewModel

  24. Q&A

  25. © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

More Related