Silverlight Adoption


Last Wednesday I had the chance to present to the first meeting of the newly formed Silverlight User Group. The topic was Silverlight and Accessibility and how to write Silverlight applications within the boundaries of the New Zealand Government Web Standards. Great to see and increasing interest in Silverlight and I’m looking forward to coming along to some more sessions over the next few months.

One of the interesting things we discussed was the extent to which Silverlight had (or rather had not) already entered the market.

So, why weren’t more people using it and what is preventing it becoming the platform of choice? Silverlight is certainly moving in the right direction to become a serious contender for delivering a rich, web based, experience for users that will rival traditional web applications. But it still has a way to go.

A few years back I remember talking with colleagues about how we have surely reached the limit of delivering rich applications over the Internet using traditional HTML/JavaScript based applications. At the time, I thought the introduction of smart client applications would revitalise the desktop market and we’d be back to the good old days of stateful, performant and rich business applications where we didn’t have to jump through hoops just to get a dropdown list to auto-complete! And then Silverlight came along and I thought, finally, we have the best of both worlds – a rich, stateful application running on a client’s machine but with the cross platform support and ease of deployment we’ve grown used to with HTML applications.

But then some genius decided to market “Web 2.0” and a whole industry sprang up around how to build richer web applications with technologies like Ajax and jQuery.

Enough already! We’ve flogged this horse to death! The Internet was never designed to build rich, transactional, LOB applications - there must be a better way.

So why aren’t we all building web applications in Silverlight right now? I think there are a few important reasons.

  • Time – the biggest factor is the time in which Silverlight has been available – these things take time. Remember Flash has been around since 1996 and Silverlight only got introduced in 2007. But even given its infancy it’s had an incredible number of downloads – Tim Sneath states, “For starters, Silverlight 2 shipped four months ago, and in just the first month of its availability, we saw over 100 million successful installations just on consumer machines.”
  • Fear – there is a perception out there that having to download a plug-in is dangerous, a security risk in a world (justifiably) paranoid about idiots who are trying to compromise their PCs. This is only heightened when it’s a new technology that you don’t know much about. Remember that Flash has been around a long time now – long enough to have gained a level of acceptance in the market that makes people more likely to accept a download. Or not have to because they already have it installed.
  • Cross Platform Support – if Silverlight is going to rival HTML based apps then it has to have the same level of cross platform support as HTML (or at least Flash). The lack of support for Mac users is a problem. Currently, unless you’re running on an Intel processor using OS 10.4.8+ you’re probably out of luck. Limited support on a wider set of browsers is also a problem. For a list of compatible OS/Browser combinations check this out.
  • Perception – most people new to Silverlight think of it as another way of playing videos in a browser – so why use Silverlight when Flash works fine. Microsoft themselves were (are?) guilty of only demonstrating the media and graphics capabilities of Silverlight. The reality is that Silverlight is much more than this and over the next year we will see more and more examples of how to use Silverlight to build LOB applications. Silverlight 3.0 has tons of new features to help you do this and I am hopeful this will make a difference.
  • Accessibility – criticism of both Flash and Silverlight have centred on a belief that they are inherently inaccessible. One of the reasons for my talk was to show how Silverlight can be made more accessible and in some cases achieve levels of accessibility not possible in standard web sites. In New Zealand at least the adoption of WCAG 2.0 was a step in the right direction but, unfortunately, we have specific exceptions to this international standard that explicitly prevent us from depending on client side web technologies regardless of the accessibility features of the technology.

I’m really looking forward to seeing where Silverlight heads – as a developer it’s an incredibly powerful platform to build Internet applications and as an end-user it has all the cool factor you could want.

I say, bring it on!

author: Tokes | posted @ Friday, July 03, 2009 10:36 AM | Feedback (0)

Building Solutions Using Microsoft Products


As promised, here are the slides and demos for a talk I did at last weekend’s Code Camp. Good turn-out of some interested and interesting people – sorry to miss the second day but still had a great time. Thanks Ivan for getting things off the ground and showing me some new dance moves.

 

image

Here’s a list of links to some things I covered in the talk.

  • SoapUI – great for interrogating and calling services and also for mocking out dependencies to products that may not be available during development
  • Moq – this was the mocking framework I used to mock an implementation of the CustomerService – again, another way to eliminate dependencies on products during development and testing.
  • Flow – a product that can help integrate disparate systems and manage the flow of data between them. In some ways Flow can be seen as a lighter weight alternative to BizTalk.

author: Tokes | posted @ Monday, June 15, 2009 2:43 PM | Feedback (1)

Wellington - Code Camp 2009


I feel a bit guilty making my first post in a (looooong) while being a pimp of a talk I’m doing this weekend. I promise to post something more interesting soon – not that my talk won’t be fascinating and thought-provoking but…

CodeCampLogo

Anyway, I’m going to be talking about the increasingly common scenario of building solutions that leverage the data and services of some of Microsoft’s major product offerings. I’ll be pitching the talk at developers who have little or no knowledge (or even interest??) in these products – even the “I don’t want to use a product when I could build it myself” brigade. I will spend some time talking about some of the key products with some examples of real life solutions. I’ll also be talking about some of the common challenges and approaches you might take when developing against products.

Don’t worry – there will be some demos and you will see some lines of code!

If you want to register then go here

See you there.

author: Tokes | posted @ Wednesday, June 10, 2009 2:31 PM | Feedback (0)

Silverlight and the New Zealand Government Web Standards 2.0


 I recently presented an Intergen Twilight Session on building applications using Silverlight while remaining compliant with the latest version of the  New Zealand Government Web Standards. I’ve posted the slides and demos here.

Version 2.0 of the standards was released March 2009. The standards are now aligned with W3C's WCAG2.0 standards, level AA, plus some additional NZ specific technical standards. Aligning with WCAG 2.0 is a great step as there is a wealth of information and tools out there.

One of the interesting NZ amendments to the WCAG standards (regarding Silverlight at least) is in relation to the use of web technologies in general. The WCAG 2.0 standard states.

Conformance Requirements (WCAG 2.0)

4. Only Accessibility-Supported Ways of Using Technologies: Only accessibility-supported ways of using technologies are relied upon to satisfy the success criteria. Any information or functionality that is provided in a way that is not accessibility supported is also available in a way that is accessibility supported.

"Accessibility Supported” is defined as,

First, the technologies must be designed in a way that user agents including assistive technologies could access all the information they need to present the content to the user. Secondly, the user agents and assistive technologies may need to be redesigned or modified to be able to actually work with these new technologies.

However, the level of assistive technology support needed for accessibility support has not been defined and is described as a “complex topic” and puts the responsibility on the wider community to establish what is acceptable.

The New Zealand Government Web Standards take a more conservative approach.

2.2 Technologies which may be used but not relied on

Scripts, applets and other programmatic objects. Information or services in webpages or applications must be available without scripts, applets and other programmatic objects. This includes Flash, Silverlight, Java and Javascript.

So this means that regardless of the accessibility features of Silverlight it can not be relied on to provide access to content and services and an alternative must be provided.

In many cases this isn’t too much of an issue. For example, it’s pretty straight forward providing access to a video transcript if the Silverlight plug-in has not been installed on a user’s browser. However, in more complex scenarios the cost of providing an alternative will be prohibitively expensive – it’s hard enough building software within existing budgets without having to double the development effort. There are approaches that can be taken and I’ll post some over the next few weeks.

author: Tokes | posted @ Friday, May 01, 2009 9:22 AM | Feedback (0)

If You’re Interested in Web Accessibility and Silverlight…


I’m doing a talk next week that will be of interest to anyone using Silverlight who wants to ensure their applications are accessible to as many users as possible. Here’s the official blurb…

Much has been written about how to make traditional, HTML based, web sites accessible. There are published guidelines, validation tools and an abundance of online resources. However, the increasing popularity of Rich Internet Applications (RIA), like Silverlight, raises interesting questions about how to achieve the same levels of accessibility.

This twilight looks at how it is possible to build highly accessible web applications by leveraging the accessibility features of Silverlight. We'll take a close look at the recently launched, ButtercupReader application that allows blind and partially sighted users to read DAISY encoded digital audio books online.

We'll also take a broader look at using Silverlight under the New Zealand e-Government Web Guidelines and discuss strategies for maintaining compliance while still leveraging the power of Silverlight.

Date: Wednesday 29 April 2009
Venue: Level 7 Plunket House, 126 Lambton Quay, Wellington
Time: 4.30pm, finishing at 5.30pm

Click here for more information and to register

If there are any specific things you’d like to cover then leave a comment – or surprise me on the day.

author: Tokes | posted @ Tuesday, April 21, 2009 3:23 PM | Feedback (0)

Adopting Agile - If There's Only One Thing You Do...


As I donned my running shoes, switched on the mp3 player and tuned in to Owen Rogers talking about Adopting Agile, I have to admit I was expecting to be disappointed. Which is not always a bad thing - I love listening to podcasts that I disagree with - especially when running - it gives me extra energy. image

In fact, listening to some dance music classics also does wonders but can have embarrassing side effects - recently I was running in what I thought was a remote forest track, stopped for a breather and broke out some rarely seen dance moves only to look up a see a small group of hunters silently staring at me through the trees. Nice. But anyway, I digress...

The reason I wasn't disappointed was that Owen said some really sensible stuff. It's one of those topics that people can get a bit religious about - and often at the expense of promoting healthy discussions and sharing ideas. Two things in particular stuck in my mind.

It's Not Helpful Talking About "Being Agile" 

Not sure if Owen used the term "Being Agile" - but it's my interpretation of a common perception that becoming Agile is actually a measurable achievement. That you can follow a checklist of practices and methodologies and claim the badge. The word itself has so many different interpretations that I've actually stopped using it in front of my clients. As Owen discusses the Agile Manifesto is the result of seventeen geeks getting together and articulating the principles they believed contributed to successful software projects. While there are more concrete practices and methodologies like Scrum and Extreme Programming it's unlikely that you will find one approach that is appropriate for all types of projects.

Owen's approach when talking to teams is to look at the immediate problems they are facing and determine whether any of the development practices or processes that are associated with the agile movement can be used to improve the situation. Every team is different, they all work under different constraints and pressures, some agile practices simply won't work and others will be a revelation. It's all about applying those practices that make sense to a particular team.

At the end of the day it's all about "Being More Agile"

If There's Only One Thing You Do...

When asked what single thing a team could do to become more agile Owen alluded to the first Agile Manifesto principle.

Our highest priority is to satisfy the customer through early and continuous delivery of valuable software

The idea being that if you achieve this you will be motivated to implement other good practices - well defined and small iterations, customer involvement, continuous integration, requirement prioritisation...

This practice is most easily understood and implemented when developing a product. It's easy to see the value of, say, Google, regularly implementing new Gmail functions every few weeks.

However, I've always found this principle to be good on paper but often hard to put in to practice within a service based company. The value of many business applications is only ever realised when they are finished. For example, I was recently involved in an Internet site that allowed customers to apply for funding online. It was a complicated series of application forms that only made sense in their entirety. It simply wasn't possible to deploy the application in stages.

Of course, the answer is sometimes to apply this principle to UAT deployments. While you're not actually adding any business value you are providing your client with a regular opportunity to review progress and provide feedback.

 

Anyway - thanks Owen for making my run more enjoyable.

author: Tokes | posted @ Tuesday, April 14, 2009 10:29 PM | Feedback (0)

ButtercupReader Gets a Blog


Buttercup Logo on Blue

We’ve been receiving lots of great feedback on ButtercupReader – people have been really supportive. To better communicate updates, discussions and information about ButtercupReader and Silverlight Acessibility in general, check out our new ButtercupReader Blog, at http://www.buttercupreader.net/blog.

author: Tokes | posted @ Friday, March 27, 2009 2:48 PM | Feedback (0)

What do Silverlight, Accessibility and Buttercups Having In Common?


Sorry for the cryptic title but I've just introduced my 5 year old boy to the timeless classic, "Princess Bride", and riddles and Buttercup came to mind... but anyway I digress. The real answer is a cool project I've been involved in called ButtercupReader - it's a showcase of how Silverlight 2.0 can be used to build an application that blind and partially sighted folks can use to read digital books (DAISY 3.0 formatted books that is).

We worked closely with Microsoft (the sponsor) and The Royal New Zealand Foundation for the Blind and in a relatively short period of time (weeks not months) we came up with a pretty cool application.

image

I'd like to showcase some of the accessibility features of ButtercupReader and talk a bit about how Silverlight could really change the way we view applications over the web.

Web Standards and Accessibility

One of the interesting aspects of this project is that, while we have built a highly accessible application, it does not comply with existing accessibility web guidelines (at least not here in NZ).

In New Zealand, like other countries, we have a set of accessibility web guidelines (New Zealand Government Web Standards) we have to follow when building sites for government departments and agencies. The goal of the guidelines is clear - to make web applications accessible to as wide an audience as possible without disadvantaging those with disabilities. And I'm totally behind this.

However, the downside to the standards is the limitations they place on building rich web user interfaces. The web is a restrictive medium at the best of times but not being able to rely on JavaScript (13.1) makes things even harder(AJAX anyone?). Of course you can invest time and effort to ensure sites degrade when JavaScript is not enabled but this is rarely affordable on typically tight budgets.

It would be great if ButtercupReader prompted a rethink in the web standards community about how we can provide accessible applications over the web.

Even building an application in HTML is itself a major limitation. We all know that HTML was never intended to be the foundation for delivering complex web applications. I remember a year or two back when  I thought the end of our obsession with the web was coming - smart clients were the promise of a new future and I could sense the renaissance of the rich client. But no, bloody Web 2.0 arrived on the scene and everyone went gaga for web again.

So when the opportunity to work on a Silverlight application came along I thought - great, the best of both worlds, a web application but with the richness of a desktop application.

Supporting Screen Readers

One of the reasons that web sites can be made accessible to screen readers is that they know how to interpret well formed HTML (as promoted by the guidelines) and can traverse a document and 'read' its contents. So what happens when you're building an application using XAML? It's pretty easy really, you can mark your XAML up with special attributes to expose accessibility information via a standard known as UIAutomation (UIA). Screen readers, and other accessibility tools, that know about UIA (or its predecessor Microsoft Active Accessibility (MSAA)) can interpret the user interface elements.

<Button    
    x:Name="openBookButton" 
    AutomationProperties.Name="Open Book"  
    AutomationProperties.HelpText="Open a Daisy book from your local computer"
    AutomationProperties.AcceleratorKey="O"
    ...>
</Button>

Using a tool like UISpy you can see the AutomationElement properties that have been exposed.

image

Mark Rideout has written a more details overview of accessibility features in his article, Creating Accessibility-aware Silverlight Content.

Other Accessibility Features

Some of the other accessibility features in ButtercupReader include,

  • Shortcut Keys - all functionality is available through the keyboard. One gotcha here is that it is not possible to override the shortcut keys used by the host browser. So, for example, we couldn't trap Ctrl + F to initiate a search. Instead, we chose to implement most shortcuts as single (standard keyboard) keys.

image

  • Self-Voicing - throughout the application, and when you set the focus to an element, you will hear speech to provide contextual information. For example, when a button receives the focus its name (AutomationElement.Name) will be spoken and when you press Numpad * additional help text (AutomationElement.HelpText) is spoken. Note that this feature relies on SAPI and will only work in IE.
  • Contrast Settings - lots of partially sighted users have a preferred contrast setting. For example, photo-sensitive users will likely choose yellow on black, whereas other users may depend on a high contrast, black on white setting.

image image image

  • Zoomability - clearly, the ability to be able to zoom into text and images is important and Silverlight makes this possible without losing any quality or definition.

image image

So you can see we've had fun on this project and I really hope it opens up some debate on the future of accessibility on the web.

author: Tokes | posted @ Wednesday, March 18, 2009 10:17 PM | Feedback (1)

Using the Silverlight 2.0 ProgressBar Control


I’ve had the chance to play around a bit with SL 2.0 recently and thought I’d share some discoveries using the ProgressBar control. It’s not quite so easy to use as you might initially think.

To illustrate this I’ve created a simple Page.xaml user control,

<UserControl x:Class="ProgressBarTest.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="400" Height="300">
    <StackPanel Background="White">
        <ProgressBar x:Name="progressBar" Minimum="0" Maximum="100" IsIndeterminate="False" Height="20" Margin="5"></ProgressBar>
        <TextBlock x:Name="progressText" Height="20" Text="" Margin="5" ></TextBlock>
        <Button Name="startButton" Content="Start" Width="100" Height="30" Click="Button_Click"></Button>
    </StackPanel>
</UserControl>

Which produces something that looks like,

image

There are a few articles (and in fact Microsoft’s help documentation itself) that simple state that all you need to do is to set the ProgressBar’s Value property and away you go. I’ve seen code snippets like this,

public partial class Page : UserControl
{
    public Page()
    {
        InitializeComponent();
    }
 
    private int _progressValue = 0;
 
    private void Button_Click(object sender, RoutedEventArgs e)
    {
        progressBar.Value = _progressValue;
        progressText.Text = _progressValue + "% complete";
 
        _progressValue += 10;
        if (_progressValue > 100) _progressValue = 0;
    }
}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

And, sure enough, each time you click the Start button the ProgressBar increments nicely. But try something a bit more realistic like,

public partial class Page : UserControl
{
    public Page()
    {
        InitializeComponent();
    }
 
    private void DoSomethingHard()
    {
        for (int i = 0; i <= 100; i = i + 10)
        {
            progressBar.Value = i;
            progressText.Text = i + "% complete";
 
            Thread.Sleep(500);
        }
    }
 
    private void Button_Click(object sender, RoutedEventArgs e)
    {
        DoSomethingHard();
    }
 
}

 

 

and you find that nothing happens to the ProgressBar until the end of the DoSomethingHard loop when the ProgressBar suddenly shows 100% complete. Not so good.

It turns out that any (long running or otherwise) user code on the main UI thread will essentially suspend any updates to any user interface elements on the page (not only ProgressBar’s). Only when control has been returned to Silverlight will it process the batched UI updates. I’m sure there’s a great explanation for this but it’s a real pain. I remember this problem when I used to code in VB (old school, that is) and the way round it then was to call the DoEvents function that would given the application a chance to process things like UI updates during intensive operations. Unfortunately, there is no such equivalent in Silverlight. In fact,

The only way to update the user interface during an operation is to have that operation performed in a different thread to the user interface.

Updating ProgressBar with BackgroundWorker

The simplest way to achieve this is to use the BackgroundWorker class. It handles spawning a new thread for you and allowing you to respond to changes to progress.

public partial class Page : UserControl
{
    BackgroundWorker _worker;
 
    public Page()
    {
        InitializeComponent();
 
        // Set up the BackgroundWorker class to do the Hard work in another thread
        _worker = new BackgroundWorker();
 
        // For some bizarre reason we need to tell the BackgoundWorker that we will be
        // reporting progress!
        _worker.WorkerReportsProgress = true;
        
        // Wire up an event handler to respond to progress changes during the operation.
        _worker.ProgressChanged += new ProgressChangedEventHandler(_worker_ProgressChanged);
 
        // Let the BackgoundWorker know what operation to call when it's kicked off.
        _worker.DoWork += new DoWorkEventHandler(_worker_DoWork);
    }
 
    void _worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
    {
        // This is the opportunity to update the controls on the main thread
        progressBar.Value = e.ProgressPercentage;
        progressText.Text = e.UserState.ToString();
    }
 
    void _worker_DoWork(object sender, DoWorkEventArgs e)
    {
        DoSomethingHard();
    }
 
    private void DoSomethingHard()
    {
        for (int i = 0; i <= 100; i = i + 10)
        {
            // Report some progress - this will result in the ProgressChanged event being
            // raised
            _worker.ReportProgress(i, i + "% complete");
 
            Thread.Sleep(500);
        }
    }
 
    private void Button_Click(object sender, RoutedEventArgs e)
    {
        // Start the BackgoundWorker thread to do the Hard Work
        _worker.RunWorkerAsync();
    }
 
}

Of course, in a real world scenario you probably aren’t running the long running process in the code behind of your control. So you won’t necessarily have access to the BackgroundWorker instance within your loop. Consider an example where you have implemented an MVP pattern.

 

Updating ProgressBar within an MVP Implementation

Consider you have a View interface defined as,

public interface IPageView
{
    event EventHandler DoSomethingHard;
}

This will be used subscribed to by the Presenter to know when to DoSomethingHard.

The Presenter is defined as,

public class PagePresenter
{
    // Define an event for the View to subscribe to to receive progress notifications
    public event EventHandler<ProgressChangedEventArgs> ReportProgressFromPresenter;
 
    public PagePresenter(IPageView view)
    {
        View = view;
        View.DoSomethingHard += new EventHandler(View_DoSomethingHard);
    }
 
    void View_DoSomethingHard(object sender, EventArgs e)
    {
        for (int i = 0; i <= 100; i = i + 10)
        {
            // If the View is listening...
            if (ReportProgressFromPresenter != null)
            {
                ReportProgressFromPresenter(this, new ProgressChangedEventArgs(i, i+"% complete"));
            }
 
            Thread.Sleep(500);
        }
    }
 
    private IPageView View {get; set;}
 
}

 

Note the Presenter has also defined an event that will be raised to notify the View of changes to it’s progress.

Our Page now provides a concrete implementation of the IPageView interface

 

 

 

 

 

public partial class Page : UserControl, IPageView
{
    BackgroundWorker _worker;
 
    PagePresenter Presenter { get; set; }
 
    public Page()
    {
        InitializeComponent();
 
        // Set up the presenter and subscribe to it's ReportProgressFromPresenter event
        Presenter = new PagePresenter(this);
        Presenter.ReportProgressFromPresenter += new EventHandler<ProgressChangedEventArgs>(Presenter_ReportProgressFromPresenter);
 
        _worker = new BackgroundWorker();
        _worker.WorkerReportsProgress = true;