Silverlight 2.0 - Concepts To Become A Silverlight Master (Series Part 3 - Blend)
In order to get a better understanding of how Silverlight applications are designed from a UI perspective, let's take quick look at the Silverlight architecture.
Notice under the WPF Heading listed are Controls, Data Binding, Layout & Editing. You might be wondering, why does this say WPF? The reason is Silverlight essentially leverages a subset of WPF technology (some parts are different) for the items mentioned. Before it was branded with the term Silverlight, it was actually known as WPF/E. Therefore, one can see that Silverlight has its roots in WPF. Furthermore, note how the WPF technology stack replaced the UI Core in Silverlight 1.0. WPF has been around since 2006, when .NET 3.0 was released. However, WPF adoption has been slowed because of poor UI tool support. In Visual Studio 2005, it was complete mess to try to write a WPF solution. Improved WPF support was finally added in VS 2008 (more is coming in .NET 3.5 sp1). However, Microsoft realized that in order to create rich/interactive applications, a first-class design tool was needed. This is how the Blend product came to be.
The Blend product is part of Microsoft's Expression Studio, which is a collection of first-class design tools. Microsoft Blend is a design tool that makes creating & editing XAML-based applications easy. Both WPF & Silverlight use XAML to declaratively control the controls, binding, styles, animations, etc., for the UI. Visual Studio is a great development IDE and has some basic design features. However, adding a full-blown designer inside the VS shell would have had poor results. Blend has been created with the designer in mind and the latest version(s) are actually written inside WPF! Expression Studio is a much needed application. Microsoft is competing primarily with Adobe AIR/Flex products. While Microsoft has the developer tools on its side (Visual Studio, C#, WCF, etc.), Adobe is the gold standard for graphical applications. Because Adobe products such as Flash, Illustrator, PhotoShop, etc., are tightly integrated and provide a designer first-class tools, Microsoft needed a strong design suite of their own.
Seperating Blend into its own product allows graphic designers to create/layout/style the application while the developer focuses on the code/data communication, etc. However, in order for this to happen, Microsoft had to leverage the ability of XAML to declaratively control layout, data binding, styling, templating, resource management, etc., inside Blend. Simply creating a second product and saying this is for designers and Visual Studio is for developers would not go over well! I think of it this way: Wherein some IT shops, DBAs are the only ones to touch the database and app developers only touch the the code. Except inside Blend, the seperation is the XAML/UI from the code behind. Hopefully, this makes sense as to why Microsoft decided to seperate the heavy design operations to another product.
By now you are probably asking yourself: So what can Blend do for me?
- Currently the Silverlight 2.0 SDK adds very little design support inside Visual Studio 2008. A developer can definitely lay out a simple application; however, harnessing the true power of Silverlight with animations/effects/styles/templating is not all there. As I mentioned above, I don't believe this will change in the RTM for the simple fact that it would be a real mess to try to add all the tools that Blend provides inside the VS shell.
- Silverlight 2.0 uses Blend 2.5 (This might change when the RTM version comes out) and this gives Silverlight 2.0 first-class design support for layouts, controls, animations, styling, templates and resource management. All these items that a developer would normally have to code by hand inside XAML are done for you simply using the Blend product.
- Blend has excellent integration with Visual Studio 2008. A developer can write a piece of code, jump to Blend, add a new control/user control and jump right back into Visual Studio and add some code behind. This is all done very seamlessly and the integration is fantastic. Blend can even build the entire Silverlight solution and perform test runs inside Blend as well! Even as of Beta 2, this integration is first class and I cannot stress the power of this feature enough.
- Blend is much more than just dragging and dropping a button and changing a color or a brush. The true power of Blend comes with the ability to spice up an application with animation/transitions/styles quickly giving a Silverlight applications that fluid/liquid interface that many compare to the iPhone for example. Blend does this by using a set of tools that expose XAML functionality (Remember, Blend just writes XAML). For example, creating a new button that looks completely different but behaves like a button is straightforward or attaching a set of transitions for mouse events is easy simple. These kind of additions not only make the UI look modern but can add visual queues, emphasis, enhanced spacial layout that were harder to do but add greater value to the application.
- Blend is not just for a designer. Not every IT department is going to have a dedicated designer able to strictly focus on pretty designs. I am not a designer. However, I dabbled with PhotoShop, GIMP, etc., and I could not do much beyond the tutorial I was using. Blend makes creating a first-class design clear once you have a good understanding of the capabilities of the product. The product definitely has the designer in mind; however, even a developer can use it and extend a Silverlight design.
- Creating advanced custom controls usually has been left to 3rd party libraries. Furthermore, creating professional looking controls demanded knowledge of GDI+ (which wasn't easy). Creating professional custom controls/user controls has never been easier with Blend. Personally, I have created simple mashup controls to pretty complex grid controls and it was actually pretty fun. In my opinion, Blend is really going to give some of the 3rd party controls a run for their money in Silverlight 2.0. The tools inside Blend drop the learning curve signifigantly for creating custom controls.
- Blend essentially gives you the tools to bring Silverlight applications to life and to design Silverlight applications using best practices for future enhancements, data binding, templates, etc.
From the list above, one can see that Expression Blend does a lot for you! This is why I feel it is a must, even for a developer, to learn Blend real well (unless you are the sadistic kind and like to crack open Notepad and hack XAML). Understanding Blend will allow a developer or a designer to bring their applications to life and harness the full power of Silverlight.
Silverlight and Multi Touch Tablets
If you follow gadget or tech sites, you probably have seen some buzz around Tablet PCs in the last couple of days. Yesterday Mike Arrington from TechCrunch posted a request to the community to help build a low-cost web tablet device with TechCrunch.
The goals of the project are simple:
low cost...about $200.00 (runs Linux)
Runs Firefox in kiosk/ATM mode. Basically, it by passes the OS and turns on directly into Firefox
i-Phone like input; touch screen
Just as the story I just mentioned was getting buzz, there were rumors posted on Gizmodo that there might be a MacBook Touch coming out in October. Obviously, these are just rumors so there are little details...but that story is real interesting as well as the timing of the story especially the day after the TechCrunch story got posted and got HUGE attention/buzz.
In the last couple of days we have a lot of buzz about two tablet products. Table PCs are nothing new; in fact, I used one back in 2003. Furthermore, Dell offers a Tablet PC as well. However, back in 2003 the multi-touch technology simply was not there (had to use a stupid stylus). The Tablet PCs were slow, handwriting recognition was poor and it loaded XP. Furthermore, the presentation technology was nonexistent. Basically, you were running an OS with a stylus on a big screen in a clunky machine. The new Dell product is basically a laptop that has a touch screen LCD panel that can rotate at a greater angle. Tablet technology up to this point has not succeeded in the mainstream. However, I think these two upcoming products can succeed. Think of it as Tablet 2.0 technology or even a Tablet relaunch :)
Apple has these things in their corner:
they are the gold standard in multi-touch & input technology
they proved they can master sleek, innovative, thin design
the current technology with longer battery life, solid state drives, improved graphics & presentation work
I think these sleek, thin web tablets are going to be the next hot thing in the next 6 months. How does this fit in with Silverlight? If you read the articles, you are probably asking yourself where you missed the Silverlight references. Both of these products obviously are not going to be formally supporting Silverlight in their plans. However, this is where as a .NET developer or company you can get a piece of the pie. Silverlight is supported on a MAC/Safari. So once the MacBook Touch launches, Silverlight will just work. The TechCrunch Tablet is a little harder because it runs on Linux. Hopefully the Moonlight project can get going again and give better support for Linux or maybe Microsoft will shock us and release a Linux plug-in. However, since the TechCrunch web tablet was just announced yesterday, I would be shocked if anything was ready in the next 6-8 months. October with the MacBook Touch (if the rumors are true) will be around the corner much faster.
Applications on the iPhone have a fluid user experience. What do I mean by that? The user has little interaction with the keyboard. It is all about scrolling, sliding, flipping, dragging while keeping things SIMPLE. Effective applications for these tablets lacking a keyboard will have to do just that and mimic the user experience from the iPhone or Microsoft Surface. Silverlight will allow you to do just that. By designing applications in Silverlight, it will allow you to bring the user experience to life. Silverlight allows you to present the layout of your application spatially and through animations/effects you can bring real time interactivity to the user. Do you think a user of an iPhone who is used to the iPhone interface would want to load an application from 2 years ago that is a step back? Of course not. This is where Silverlight compiled code rocks because it is ultra responsive and nothing out on the web can compete with it.
Silverlight is a web technology and it is distributed through a plug-in. This is a perfect way for Silverlight applications to sneak onto the tablets and get some of the attention of the user base. This is why I am such a big advocate of Silverlight technology; because of how well it can complement the user experience in this example and others. You know users will demand high quality and responsive interfaces (the iPhone generation is spoiled) and Silverlight is one way to spoil them even more. Silverlight: learn it, use it and abuse it. Hopefully, this article gave everyone a glimpse into the future on why it is a good idea to invest time in learning Silverlight. It would be even better if the article gave you some ideas of applications/tools to write for the upcoming web tablets!
Silverlight 2.0 - Concepts To Become A Silverlight Master (Series Part 2 - WCF)
Series update: I changed the name of the series as the name was slightly confusing.
Silverlight 2.0 technology is based on a web plug-in that runs on the client's computer. Writing applications/tools/games that don't depend on data is straightforward and doesn't require the Silverlight developer to think much beyond the client's domain. However, what if the developer wants to introduce external data into their Silverlight 2.0 application?
First, the bad news:
- Silverlight 2.0 currently runs on a small subset of the .NET 3.5 Framework. This means some of the "direct" data channels/communication libraries are not available to you (i.e., remoting, COM, database, etc.)
- Silverlight hosts its app domain on the client's workstation. This means that even though it is a web technology hosted on a web server, it can't leverage resources on the web server that do not cross the web server domain (i.e., database calls, local dll files that call a database, local dll files that consume a service)
- Another limitation is that because Silverlight utilizes a minimal/secure plug-in architecture, you cannot access local workstation data channels easily. For example, a fat client windows application can call a database, windows/web services, make remote calls, etc. Most of these (as you guessed it) are not available to you.
So HOW can I consume some data from an external data source? Silverlight 2.0 Beta 2 currently supports these communication channels:
As a developer, what is the best way to design services that a Silverlight plug-in client can consume? Luckily, this is where WCF comes in (Finally, the meat of the article).
WCF is an acronym for the Windows Communication Foundation, which was introduced in .NET 3.0. WCF (like LINQ/.NET) is one of these technologies that is hard to summarize in one good definition. Some developers simply say WCF is web services or a way to design SOA. My definition of WCF is actually not mine. This definition is from Juwal Lowy's forward from his great book Programming WCF Services:
"WCF is a fundamental technology that provides an easy and clean way to generate services and applications in compliance with what I regard as sound design principles."
WCF (without going into too much detail) allows you to architect applications by applying best practice guidelines automatically. Security, throttling, opt-in serialization, logging, etc., are handled for you just by creating a service inside the WCF framework and setting config/attribute values. Juwal Lowy (in web casts/book/classes) says you can spend time writing plumbing code and trying to adhere to best practices or use WCF and allow it to do the majority of the work for you.
Silverlight runs on a subset of the .NET 3.5 framework, so it does not support all of the WCF bindings and can't consume every type of WCF binding/endpoint. However, from the list above utilizing WCF (as your service engine) you can design: SOAP 1.1 Services, Duplex Services, AJAX Enabled Services & REST Services. All of these can be consumed by the Silverlight 2.0 client.
A great aspect of WCF is that it allows you to write your application and expose it using various binding endpoints supported by Silverlight. Furthermore, existing WCF services can simply be "Silverlight enabled" by providing a compatible Silverlight endpoint. Depending on the functional requirement, of course, this might not be possible.
The diagram below demonstrates the same services being consumed by different clients using different endpoints:
Quickly doing a search on services+Silverlight, you will notice that WCF comes up a majority of the time. Microsoft is pushing WCF heavily as a best practice for writing services for Silverlight. In fact, after installing the Silverlight 2.0 SDK, you have a new template called "Silverlight-enabled WCFService" for quickly creating WCF services that can be consumed with Silverlight.
Silverlight 2.0 Beta 2.0 allows the developer to configure the WCF service inside a ClientConfig file. This is a real nice add for additional configuration of WCF services, especially if you are a software vendor that needs to change connections/tweak settings for different deployments declaratively.
WCF (in .NET 3.5) has great support for creating RESTful services. RESTful services are used all over the place: Flickr, MySpace, Amazon, etc. WCF allows you to quickly create low/high REST services that can use XML, JSON or RSS encoding. Silverlight can consume these easily. In fact, many examples online show this by communicating with external REST services and manipulating the data on the client (i.e., using LINQ).
Summary of benefits using WCF to consume data in Silverlight:
- All the different Silverlight service types can be designed with the single WCF technology. Basically, anything you can do with other service design you can do with WCF. However, with WCF you are doing it with a single technology
- Allows the developer to design services focusing less on implementing best practices and plumbing code (WCF's biggest selling point, since it does a lot for you out of the box)
- WCF endpoint abstraction allows the developer to create service endpoints for both Silverlight and non-Silverlight consumers (while sharing the same code)
- Microsoft recommended best practice. WCF includes first class support in Silverlight: online examples, Silverlight-enabled WCF service template and clientConfig XML configuration file
- Best practice for the future. As Microsoft adds additional support to the Silverlight service stack, developers can be assured that probability-wise this will be done via WCF. For example, Duplex services (introduced in Beta 2)
In summary, Silverlight and WCF technologies complement each other very well. WCF is a single technology that provides you a single design mechanism to create a variety of solutions for exposing your data to a Silverlight client. WCF is not a requirement in order to consume data inside Silverlight (lots of examples online with 3rd party REST services). However, because of how well it works with Silverlight and deprecates other SOA design (at least in the MS world), it is a no-brainer that WCF is recommended by Microsoft. In my opinion, WCF is a technology every developer needs to master in order to be effective with consuming data inside Silverlight.
Silverlight 2.0 - Concepts to become a master series (Part 1 - .NET/C#)
Silverlight is THE next generation rich web technology to learn if you are a programmer focusing on delivering web content. There are many articles out there on how to get started or how to write your first Silverlight program. However, many of these articles fail to address the specific knowledge you need to master to be a truly effective Silverlight programmer.
Silverlight, just like any technology, has a concrete matrix of concepts a programmer should focus on in order to be able to call himself a master of the technology. Fifteen to twenty years ago (before the web, before mobile technology, before networks were prevalant, etc.), you could have an almost complete grasp of software engineering by focusing just on a few skills. As software engineering started to mature and the web blew the door off the amount of new technology/processes/patterns available, it became impossible to be an expert in every single facet of software development. Silverlight is just a small thing right now in the bag of technologies available for developers to learn. However, the Silverlight technology demands that you are productive with certain concepts in order to become an effective developer with the technology. Learning a new technology like Silverlight can be a daunting task with the limited R&D time developers are afforded. Furthermore, not knowing which technologies Silverlight relies on to deliver complete solutions can definitely pose a challenge in trying to learn on your own blindly.
I have been working with Silverlight since Alpha 1.1 -> Beta 2 (on and off; mostly on since Beta 1) and there are certain subject matters that demanded my deep understanding in order to use them effectively in Silverlight. Instead of creating a massive post, I decided to create a series of posts about the core concepts a Silverlight developer needs to focus on. The goal of the article is to help developers getting started with Silverlight 2.0 understand what technologies they should get familiar with or which technologies to brush up on in order to learn Silverlight in the most efficient way.
Silverlight 2.0 is a Microsoft technology platform. Like all new Microsoft platforms, in order to develop on it, you have to know .NET. That's a given. Silverlight 2.0 runs on a subset of the .NET 3.5 framework which has a very small footprint. However, the Silverlight team managed to add a great deal of libraries (even lots of .NET 3.5 items) inside this sub system. Obviously, I don't think this comes as a shock to anyone that in order to program in Silverlight 2, you will be developing on .NET. Since you will be coding in .NET, it also makes sense that you will be coding inside Microsoft's flagship IDE Visual Studio. Visual Studio 2008 has great integration with Silverlight 2.0 with debugging/design/projects, etc. This is one of Microsoft's strong points. Architects/Sr. Developers debate platforms/languages (dynamic/functional/OOP), etc. all the time. However, what is not debatable is the fact that Microsoft Visual Studio is one of the best programming environments out there. Visual Studio/.NET are pretty much a requirement...no shockers here.
What is controversial is my opinion that your .NET language of choice should clearly be C#. Silverlight 2 is currently in Beta 2 release. For the most part, I find that the early adopters of any new technology are usually advanced developers. Like it or not, that trend usually applies to C# development over VB.NET. Let's take some examples:
If you right now want to find an article about Silverlight and a code example, the chances are 85%+ that this example will be exclusively in C#. Does that mean VB.NET developers can't learn Silverlight? No, I am simply saying that you have a MUCH easier time as a C# developer if you are reading examples in your native/favorite language.
The absolute best resource when learning a beta technology is blogs. Bar none. The Silverlight 2 books are just starting to come out in "beta" and Microsoft's own libraries are just starting to be populated and are not a great resource yet. However, blogs are great for beta technology as they allow you to overcome bugs/issues/undocumented concepts, etc. that plague beta releases. Most advanced bloggers blog in C#. This ties into my previous assertion that more advanced programmers prefer C#. Furthermore, C# has many shortcuts that allow bloggers to post clear/concise code while getting the point across. This is yet another advantage C# bloggers use when posting about Silverlight. Check out some samples on Jesse Liberty's blog
, Tim Heuer's blog
Magazine articles are your next best friends. They are dominated by C# syntax as well. I subscribe to ASP.NET and Code magazine (I used to get MSDN Mag when I had a MSDN Sub) and a majority of the code is in C#. Note: The only time I have seen a real master coder write in VB.NET almost exclusively was Dino Esposito
. I do think though after he went to idesign, Juwal Lowy straightened him out, as he has now been posting in C# :)
Microsoft documentation is 50/50 C# and VB.NET. Obviously, this case is a draw.
I am not saying that you cannot learn Silverlight without C#; just that I have found that it makes my life a lot easier. Imagine you are a VB.NET developer working on an issue and you are ready to throw something and you try to enter your problem into Google. The search engine pops up with a solution and then you see the delegate word being thrown around (anon methods) or the => symbol. Obviously you will have to decipher the syntax first before proceeding. Furthermore, I think as you become more senior with the C# advanced syntax, it actually becomes HARDER to read VB.NET. I completely disagree with MS's position that it doesn't matter. As the RTM approaches, this might change as more books appear (this tends to still favor C#, but less percentage-wise).
If you are just getting started in .NET by being drawn to Silverlight, I think you will have a much easier time learning Silverlight if you learn C#. Doing so will give you access to many more current samples/projects online in a native language.