Home > English > Microsoft Silverlight 5 Data and Services Cookbook

Microsoft Silverlight 5 Data and Services Cookbook

I wanted to continue on reviewing books related to Silverlight 5 and development.  Microsoft Silverlight 5 Data and Services Cookbook states that it has over 100 practical recipes for creating rich, data-driven, business applications in Silverlight 5.  As with my last review, I will go over each chapter and add any gut reactions towards the content it provides.

The book is broken down into 13 chapters as well as an appendix.  On the whole, the book has a lot of content to absorb.  It is broken down into a collection of tips and tricks and common scenarios for using Silverlight in building line of business applications.  I like the concept and idea behind the approach to this book but I find that a lot of corners were cut in getting the book out the door.  I wish that the book had a better quality of code snippets as well as accompanying images as the code samples lack syntax highlighting of any sort and the images are very poor in quality.

Chapter 1 is all about learning the nuts and bolts of Silverlight 5.  This chapter is necessary if you have never written a Silverlight application and need to understand what is required in order to get started using Visual Studio 2010.

Chapter 2 jumps right into covering Data Binding.  This is also a core concept to any XAML technology and I like that they cover it soon so as to get you exposed to the whole data binding programming paradigm.  You are exposed to the classical non-data binding approach and then launch into the concept of a DataContext and how the data binding mechanism works.  We exposed how to create bindings both in XAML as well as in code which is sometimes necessary.  Binding to other elements, and collections is also discussed.  Next, is introduced the interface, INotifyPropertyChanged.  This is by far one of the most important aspects of XAML programming as it facilitates two-way data binding.  We finally come to one of the first instances of a new feature of Silverlight 5, debugging data binding expression.  This is one of the coolest features of Silverlight 5 and makes developing in Silverlight 5 a joy.

Chapter 3 takes our knowledge that we learned from data binding and goes into some advanced topics.  Namely, we are presented with converters, data templates, validating.  Converters are required in most line of business applications as your data binding alone will not satisfy all of your business logic and requirements.  We are also presented TargetNullValue, StringFormat, and FallbackValue as alternatives for using converters.  Another important part of any line of business application is validating user input.  We are presented with NotifyOnValidationError and ValidatesOnExceptions.  In the UI, we are introduced the ValidationSummary control that will automatically receive any BindingValidationError events.  This is nice in that we can present all errors in one concerted location and effort back to the user.  Data Annotations are presented as a means for providing validation rules on your domain objects.  INotifyDataErrorInfo and IDataErrorInfo interfaces are introduced to show how you can validate user input without throwing exceptions.  We finally move away from validation and review data templates.  This is an important concept with any XAML technology and we find good examples of usage here.  With Silverlight 5, we get the ability to use implicit templates and this is covered as well.  For scenarios where we need to binding something different than our current element in the visual tree, we are presented with Ancestor RelativeSource binding now available in Silverlight 5.  Another powerful feature of Silverlight 5 is the ability to create custom markup extensions.  Finally, as with INotifyPropertyChanged works on a single object, we are presented with the INotifyCollectionChanged interface for dealing with change aware collections.

Chapter 4 is completed dedicated to the Data Grid.  The one aspect that I was curious about was how they demonstrated binding combo boxes to the a column in the data grid.  The sample was very primitive and would not be something you would really be able to use in most data driven scenarios.  I am hoping that as we move to MVVM, we will see better scenarios on this.

Chapter 5 is about Isolated Storage.  This chapter does a good job on covering Isolated Storage and the limitations of Silverlight applications and their security sandbox.  I also liked that they also showed how you could use the Sterling database.

Chapter 6 covers MVVM.  The chapters covers the basics of MVVM as well as introducing MVVM Light and MEF as tools to use with MVVM.  I would have like an introduction on Prism and Caliburn.Micro as well as these are two important frameworks and libraries.  With Caliburn.Micro, they could have provided a nice introduction to architecting rich user interfaces without explicit data binding in your XAML.

Chapter 7 covers services.  Most all line of business applications will require data and since you cannot create a direct connection to the database in Silveright, you will need to access a service.  You presented with services such as ASMX, WCF, REST, and RSS.  I also liked that they also had a section on socket communication in Silverlight as well.  The one complaint I have is that I wished they would have also introduced SignalR as section as this is gaining a lot of popularity in the .NET community.

Chapter 8 takes what we were introduced in the previous chapter and focuses strictly on WCF and ASMX services.  We are exposed with using services that expose data, using Bing as a service.  We get presented with performance tuning by using binary XML.  We also cover a personal favorite of mine, the infamous, “Server Not Found” exception and how to provide more information to the Silverlight client.  Integrating with ASP.NET Authentication is also covered.  Finally, we are presented with uploading files using WCF.

Chapter 9 takes us one step further in our discovery with ASMX and WCF.  Mainly, we cover duplex communication, data encryption, message-based security, using Windows Identity Foundation and, finally, using a ChannelFactory with Silverlight.  Most of these sections are very high level and don’t go any further than a quick sample.  It at least points you in the right direction for further investigation.

Chapter 10 talks about using REST and WCF Data Services.  With REST we cover both XML and JSON formats.  Another sections discusses the limitations to the Silverlight browser stack.  We are then presented with the ClientHttp stack and how we can use the common REST verbs.  Next, we are presented with using WCF Data Services.  We also get presented with Flickr and Twitter and how to use their REST services.

Chapter 11 is dedicated to presenting WCF RIA Services.  While I am not a big fan of WCF RIA Services this chapter does a good job at showing you what you can do with WCF RIA Services.  It walks you through using the class library, getting your data, using a LoadBehavior, server-side queries, sorting, filtering, paging, and finally persisting your data and dealing with transactions and concurrency.

Chapter 12 continues on the WCF RIA Services and shows us some advanced features.  We are shown how to get a user’s identity either by Windows authentication or a custom means.  Next, we are presented with using Windows Identity Foundation and WCF RIA Services.    We then move from authentication to authorization in our services.  We also review how WCF RIA Services supports data annotations and validating user input.  Finally, we are presented with exposing our data via OData endpoints as well as SOAP or a JSON/REST endpoint.

Chapter 13 introduces Windows Phone 7.  This chapter walks you through the WP7 architecture from a developer’s perspective and then concentrates on getting data to the device.  A lot of the same patterns presented in the previous chapters are applicable.  Using push notifications with the cloud is demonstrated.  Local storage using a SQL CE database is presented.  Finally, a sample on using background transfer service is covered for uploading and downloading files in the background.

Appendix.  The appendix walks you through how to find any of the dependencies mentioned in the book.

If you are looking for a book that covers a lot of scenarios in Silverlight concerning data and services than this seems like a good reference for you to have.  At times, I feel that the samples were overly verbose and cluttered but I believe this is more to be the fault of poor publishing.  It would have been nice to have a better rendering of the code snippets and a better quality of the sample images throughout the book.  All in all, I found the book to be a good reference and it will definitely go in my toolbox as a go to book when I am working on a particular scenario.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: