Silverlight 1.1 case study: Carbon Calculator

One of the Web's first Silverlight 1.1 applications is a carbon calculator built for Conservation International. The app's developer told his tale at ReMIX07 Boston, sharing thoughts on what worked well -- like XAML, LINQ and designer-developer workflow -- and what was a challenge -- like building controls from scratch.

At the end of May, Applied Information Sciences began work on a Silverlight-enabled version of the Conservation International's Carbon Calculator. Since the original application was JavaScript and straight HTML, Silverlight 1.0 seemed a good choice. But the .NET developers at Applied Information quickly switched to Silverlight 1.1, even though it was still an alpha release.

When you are building these applications, keep in mind that you are dealing more with a WinForms app than with an ASP.NET app.
Pete Brown
lead architect and project managerApplied Information Sciences

Those developers, Pete Brown and Steve Suing, had a tight timetable -- Conservation International wanted the Carbon Calculator live by July 7, 7/7/07, the day that Live Earth concerts on six continents raised awareness about global warming.

Though the going was tough at times -- animation support was rough around the edges, controls had to be written from scratch and error handling was reminiscent of VB 5 -- the tough got going, and the Carbon Calculator was finished on time.

"It is a production application built on an alpha product. As far as I know, it is the first Silverlight 1.1 application to go into production," Brown, lead architect and project manager at Applied Information Sciences, said during a session at the recent ReMIX07 Boston. Of Silverlight 1.1 alpha, he said, "There was an awful lot in there that was already working."

The Carbon Calculator lets site visitors determine their carbon footprint, which is the amount of carbon dioxide they are personally responsible for emitting into the Earth's atmosphere. Once a user is finished with the survey, the application calculates how much he or she would have to contribute to offset those emissions and redirects to a donation form.

Brown and Suing took the existing application, which was little more than an ecommerce site, and rewrote it in C#, leaving intact the algorithms and other data that Conservation International uses to calculate one's carbon footprint. The developers added a Microsoft Virtual Earth mash-up, which uses a JavaScript integration layer, to integrate map animations into the survey. Finally, the entire application was hosted on Microsoft Office SharePoint Server 2007, to which Conservation International was migrating and which provided the lists that populated the application's controls.

Integration of SharePoint 2007, Virtual Earth and JSON Web services went smoothly, thanks largely to XAML, LINQ and other features of Visual Studio 2008. Brown said. So, too, did the designer-developer workflow work well -- partly because it was a two-man team, admittedly, but also because Brown and Suing established that which could not change early on and made sure that code did not change.

However, as one would expect with alpha version software, obstacles did arise.

First, since Silverlight 1.1 lacks controls, and third-party controls are still few and far between, "We spent the majority of our time writing from scratch drop-down ListBoxes and other controls that you usually get for free," Brown said.

This partly explains why the application uses a redirect to the Carbon Calculator's donation form. "Rolling our own TextBox control was way beyond the scope of what we were doing for this project," Brown admitted. In addition, Conservation International wanted to maintain the ability to update the form from time to time, which would have involved re-coding the control. Finally, pop-up blockers are not familiar with Silverlight, so taking query string parameters and loading them into a new browser window was far more desirable than allowing pop-ups and watching a page refresh erase all the data a user has entered into the application.

More on Silverlight development
Case study: Silverlight shine seen in video editing application

Reference: Silverlight Learning Guide: v1.1 Alpha Tutorials

References: Links from Pete Brown's ReMIX07 Boston presentation (IrritatedVowel.com)

Download: Silverlight development tools (Microsoft)

The underlying structure of the application presented another challenge. Again, Applied Information Sciences had to build the controls from scratch, and Brown wanted a survey that would be easy to build and simultaneously intuitive and recognizable to end users.

The solution came from tried and true Visual Basic 6 implementations -- UserControl screens built as "a series of wizard-like controls." Each screen is its own XAML file and sits atop the main page.xaml document. UI elements, in turn, sit atop the UserControl screens.

This model worked well because Silverlight applications, like Ajax applications, present state issues that traditional, Web 1.0 applications cannot confront, Brown said. As he put it to the audience, "When you are building these applications, keep in mind that you are dealing more with a WinForms app than with an ASP.NET app."

The downside, of course, is that model makes the survey look like a lot like a Windows application with rectangular boxes. Given that Silverlight 1.1's animation support improved dramatically from the May release to the September release, Brown said that, were he to do it over again, he would have included more animation.

This Content Component encountered an error

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

SearchSOA

TheServerSide

SearchCloudApplications

Close