Diary of a trip to the UK and Ireland – Pain in the Ash

Dateline 21-April-2010 St. Andrews Scotland

The User Group meeting in Dundee (“Silverlight From Zero”) and in the shockingly beautiful city of Edinburgh (“Silverlight LOB Applications Development with MVVM and TDD”) both went very well.  The turnout was good at Dundee and extraordinary in Edinburgh, with a very warm reception in both cases.

It turned out that my very nice if somewhat small hotel in Dundee had no booking for me on  the 19th or 20th….

Continue reading →

Posted in Community | Tagged , | Comments Off on Diary of a trip to the UK and Ireland – Pain in the Ash

Diary of a trip to the UK and Ireland – User Groups

Dateline: Newcastle Upon Tyne, 17-April  09:44 BST

Another terrific experience last night, speaking at a room in Newcastle University to a group of professional and intrepid coders. I’m told that setting a meeting on Friday night is a recipe for talking to an empty room, so I’m very grateful to the throngs (okay, the small gathering) that showed up for Silverlight, HVP, Test Driven Development, MVVM and most important, pizza and American beer.

Continue reading →

Posted in Community | Tagged | 8 Comments

Diary of a trip to the UK and Ireland – Continued

Dateline Hetton, near Skipton.

Kings College The presentation in Cambridge was great fun, preceded by a quick walking tour with Rachel Hawley (who, it turns out, I’ve known thrice without understanding she was all the same person!  She was involved in hiring me to write a (mostly) political column in 2006/2007 for Simple Talk, then again in helping me with CodeRush and finally with arranging the Cambridge part of my trip, not least acting as tour-guide.

Continue reading →

Posted in Community | Tagged | 6 Comments

Diary of a trip to the UK & Ireland – Day 3

Dateline London 14-April 2010

MagicRoundaboutYesterday (Tuesday) was terrific.  The drive from Bristol to London was punctuated by a quick side-trip to  drive through the Magic Roundabout (you didn’t think I could resist, did you?)  It was brilliant.  You can go all around, but you don’t, and it is not at all confusing or difficult. It is very straightforward.  First I drive from the entry at the bottom of the map to the first exit (pointing directly to the left).  Then I reentered and cut across the center to go out M4, which I realized later is the yellow arrows in the illustration in yesterday’s post.

Then, on to London. Now, I drive in Boston and have been a cabbie in NY, but nothing quite prepared me for London, downtown, rush hour.  I opted to put the car in a car park and walk around, but the spots were fairly tiny (of course, right after passing up one spot as too small, I watched a woman younger than my daughter effortlessly back into that very spot in her minivan!)

Continue reading →

Posted in Community | Tagged , , | 8 Comments

Diary of a trip to the UK & Ireland – Day 2

A Massachusetts Yankee in Queen Elizabeth’s country.  It will take a very (very) long time for me to be able to walk up to a woman I don’t know (such as at a hotel or in a restaurant) and say “Excuse me, can you tell me where I find the toilet?”  Unless Guy Smith-Ferrier is winding me up, that is very much the normal way to ask, and no one things a thing about it.  He seemed quite surprised that I’d have any hesitation!

Second, all in all, the traffic engineering here is far superior to the States.  The bad news, and I can’t imagine the reason, is that they don’ have left-on-red (in all of the US except New York City, if you come to a red light and you are making a right turn, you may come to a full  stop and then if it is safe, you may continue.)

Continue reading →

Posted in Community | Tagged | 6 Comments

Diary of a trip to the UK & Ireland

I’ve been looking forward to this trip to the UK & Ireland for months, and I am extremely happy to be here.  I will write and speak about all of this from the “Microsoft Community” perspective , but this blog post is a personal, and on going, diary of an American stepping through the looking glass.

Now, I’ve been here before (England in 1972, England, Scotland and Wales in 1976, England and Wales in 1985). Ah, I was so much older then, I’m younger than that now.

Driving

I did drive here in 72 and 76, so of course I didn’t hesitate to rent a car, despite the rather alarmed tone in Guy Smith-Ferrier’s voice when he asked, thrice, if I had driven on the left before. 

On the other hand, driving a stick for the first time in 10 years, with the steering wheel in the passenger’s seat, driving on the left, after flying across five time zones, in downtown London, at night,  may not have been the best plan. 

Most of the time, it it really isn’t a problem, everything more or less makes sense. But  the brain begins to overload at 60 mph when it is trying to assimilate the basic rules  like “keep left except to pass,” and you are seeing signs that have somehow gone through the looking glass (is that 60 in a circle the speed limit?), road markings that don’t quite make sense (what, for God’s sake is a blue rectangle with a single white slash?) and you are seeing some of the most beautiful gothic buildings juxtaposed with electronic adverts for Wired Magazine.  It all goes by in a flash, and while, shockingly, there are no flashing blue lights in the rear view,  it is clear you’re not in Kansas anymore.

Then you get off the M-way, and soon  a bus is heading at you in the dark, you have to make a right turn, he’s on the wrong side,  and the GPS is barking commands like “make a right here damn it!”

More soon…

(By the way, the elevators here are zero-based; a C programmer’s world if ever there was one)

This work is licensed under a Creative Commons license.
Posted in Community | Tagged | Comments Off on Diary of a trip to the UK & Ireland

New Video Series – Getting Started With Silverlight

I’ve begun a new series of videos on Silverlight that begins with installation and creating a simple grid with two controls, and that will, over time, cover an entire course of Silverlight applications programming.

Each video stands on its own, but my hope is that put together they will provide a complete survey of Silverlight programming.  The first two videos in the series are Getting Started With Silverlight and Adding Controls To A Silverlight Application.

twitter_48 I will tweet about each video in the series as it is released, and all of them will be listed here.

Note, the new Twitter bird is from the generous folks at Function Design.

This work is licensed under a Creative Commons license.
Posted in z Silverlight Archives | Tagged , , | Comments Off on New Video Series – Getting Started With Silverlight

An Annotated Line of Business Application

MiniTutorialLogo

The Silverlight HyperVideo Player has met with strong support and interest. This mini-tutorial is the first in a series that will walk through the design and delivery of this project.

This series will pretend that the design existed before we began coding, and will not take you through its evolution over the months between December 2009 and March 2010. In short, this series is a “drop-line” exercise highlighting how the program works with a focus on teasing out general principles of creating mid-sized line of business Silverlight applications.

Understanding the Silverlight HVP

If a picture is worth a thousand words, a video must be worth an order of magnitude more. This video, created as part of the HVP sample set, explains the concepts behind the HVP.

Design Guidelines

I’m a big believer in diving right into the code, but I did want to mention just a few of the design/coding guidelines I imposed on myself when writing this, and we can explore their motivation, implications and outcome as we go:

Overarching message of the code: Silverlight is an application development framework: treat it like one.

  • Write Clean Code
  • Use Test Driven Development
  • Let the Design Emerge
  • Understand that the first version is just the launching point for subsequent versions
  • Community involvement (including design and coding) should grow over time
  • When possible, illustrate “best practices”

Getting Started

The premise of agile programming dove-tails neatly with the approach I’ve been advocating for two decades: get it working and keep it working.  I can’t claim any high minded values behind this; it is just what works for me. Worse, it is what I end up doing, even when I’m supposed to be doing design-first.  I simply can’t design in a vacuum and I get very tired and crabby when I do try to design in advance because it doesn’t work. It never works because

  • I learn more about how I want the design to be as I write code
  • Requirements change
  • The bigger the design, the more likely I am to get it wrong
  • Requirements change
  • The bigger the design, the more reluctant I am to change it
  • And requirements change

The old argument was “don’t paint yourself into a corner.”  On reflection, what I found was I was always painting myself into corners, but if I only painted for a few minutes before fixing the problem I was a lot better off than if I’d spent all day at it.

Emerging Design

I love the term emerging design because it sounds so much better than “figure it out as you go.”

We’ll come back to the most effective technique I know of for making all this work in large complex applications when we talk later about Test Driven Design, but let’s get started.  Here is what I know:

  • I want the program to be created from independent components, and MEF will provide a great solution to that.  MEF is non-trivial, however and I don’t want to deal with anything that complex until I have something working.
  • Creating a media player is lots of fun, lots of folks have done it, most of the implementations suck. There are Microsoft folks working on an open source solution (The Silverlight Media Framework that they, for some bizarre reason, refer to as the “Smurf”) that not only doesn’t suck (except its acronym) but is really good.  Let’s use that.
  • MVVM is hot stuff.  Moreover, it’s hot stuff for all the right reasons. Let’s use that.

The First Thing To Get Working

One of the premises of “Emerging Design” that I like  a lot is this: don’t design anything until you’re going to implement it.  Do not say to yourself “I know I’m going to need this, so let me put in all the hooks I’ll need.”  Reason: when you predict what you’ll need, you are usually wrong. Work done today does not save you work later, but work not done today may never need to be done at all.

In that spirit, the first thing to do is to create an application that has the Silverlight Media Framework player in it, and get that working in a very simple page.

I’m going to re-create the source bit by bit, and make that incremental source available with each mini-tutorial (see bottom of this posting)  but please understand that these are not the versions that I created the first time. I’ve condensed the process here to facilitate focusing on what matters, and to reduce confusion. You can find all my dead-ends, mistakes and changes of heart enshrined in the source code history here.

Since adding a SMF is a well documented and short set of steps, I’ll just take my lead from the SMF documentation and create a simple Silverlight Application named HVPT1 (Tutorial 1). That will create two projects: HVPT1 and HVPT1.web.  The startup project will be HVPT1.web, the startup page will be HVPT1TestPage.aspx and the first Silverlight page will be in the HVPT1 (client side) project, the file mainpage.xaml

Getting the SMurF Libraries

For the SMF to work, we need the four SMF libraries, which can be downloaded from here, as well as the IIS Smooth Streaming Player Development Kit which is available here.  The Smooth Streaming Player Development Kit (SSPDK) is unpacked by double clicking on the downloaded .exe.  Place all five DLLs (the four from the SMF and the unpacked SSPDK into the same directory.

In HVPT1 add a reference to all the DLLs except SilverlightMediaFramework.data.dll and then replace the header of HVPT1.MainPage.xaml with the following:

<UserControl x:Class="HVPT1.MainPage"
    xmlns:p="clr-namespace:Microsoft.SilverlightMediaFramework.Player;assembly=Microsoft.SilverlightMediaFramework.Player"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignWidth="640"
    d:DesignHeight="480">

Note that the second line declares a namespace alias “p” that refers to the Microsoft.SilvelrightMediaFramework.Player.  You can now declare the player and its source, which must be a streaming media file. Here’s the entire .xaml file:

<UserControl x:Class="HVPT1.MainPage"
    xmlns:p="clr-namespace:Microsoft.SilverlightMediaFramework.Player;assembly=Microsoft.SilverlightMediaFramework.Player"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignWidth="640"
    d:DesignHeight="480">

    <Grid
        x:Name="LayoutRoot">
        <p:Player>
            <p:CoreSmoothStreamingMediaElement
                AutoPlay="True"
                SmoothStreamingSource="http://video3.smoothhd.com.edgesuite.net/ondemand/Big%20Buck%20Bunny%20Adaptive.ism/Manifest" />
        </p:Player>
    </Grid>

</UserControl>

Build the application and watch the streaming movie. There is nothing more satisfying than getting something (anything) working!

SMurF

SaveBlue


Download the source code

This work is licensed under a Creative Commons license.
Posted in HyperVideo Player, Mini-Tutorial | Tagged , | 5 Comments

Silverlight HVP on Silverlight TV

JLSLTV2

 

The Silverlight HyperVideo Project has made two guest appearances on Silverlight TV. 

In the first, I talk with John Papa about the project itself and how it has evolved.

Then, during Mix, Tim Heuer and I sat down with John to discuss What’s New In Silverlight 4, and I managed to sneak in a few comments about the HVP as well.

Silverlight TV has numerous great interviews, and is quickly becoming a valued asset throughout the Silverlight community. 

SilverlightTV_100px

Tens of thousands of people view each episode. Check it out here.

Then take a look at John Papa’s site as well.

Then come back here, because the last thing I want is for you to decide you like JP so much you stop visiting. Next thing you know, I’m sitting in the dark.

 

This work is licensed under a Creative Commons license.
Posted in HyperVideo Player | Tagged , , | 2 Comments

WCF Ria Services For Real

MiniTutorialLogo

In my previous post I discussed creating the database and tables for the Silverlight HVP configuration data.  All that was great, and worked just dandy until it was time to get the data from the database server to the application running on the client.

“But,” I thought, “How hard can it be?”  I’ve done a few mini-tutorials… should be straight-forward… And it was… sorta.

Continue reading →

Posted in z Silverlight Archives | Tagged , | 6 Comments

Persisting the Configuration (Updated)

MiniTutorialLogo

[Updated and expanded on March 5]

HVP-Config-DB For this week’s release of the Silverlight HyperVideo Platform we are committed to having configuration information retrieved from a database. To accomplish this we need (want?)

Smooth-streaming videos that we can use to illustrate the relationship among Items, Topics and Links and

A Database in which to store the configuration information

Step 1 was accomplished by

  • Creating the videos
  • Creating image files
  • Uploading the videos and images to MSN where the videos were encoded for smooth streaming and URLs were returned for the image and for the video
  • Watching the videos and noting where we want to mark topics and links
  • Adding that information to the database

Step 2 was accomplished by creating a Database with four tables

  • Listables
  • Items
  • Topics
  • Links
The Listables table’s relationship with the other three is isomorphic to the relationship between the Listable base class and the derived classes Item, Topic and Link. All of this is captured in the database diagram shown above.

Foreign Keys

[sql]SELECT dbo.Items.ID AS ItemsID,
dbo.Items.ItemUri,
dbo.Listables.ID AS ListablesID,
dbo.Listables.TextToDisplay,
dbo.Listables.ImageSource,
dbo.Items.MyListableID
FROM dbo.Items INNER JOIN
dbo.Listables ON
dbo.Items.MyListableID = dbo.Listables.ID[/sql]
The Sets, Items, Topics and Links tables each represent part of an object, with the remaining part held in Listables. This “normalization” of the database reduces the duplication of data, and thus reduces the likelihood of database corruption.

The Sets, Items, Links and Topics tables each have a column titled MyLinkableId which is a foreign key linked to the key ID field in the Linkables table. This lets us create views such as this definition of the ItemsView

As shown in the image, the column MyListableID in Items and the column ID in Listables are used to join the two tables together into a complete Item.

An Item’s Links and Topics

The second set of connections from each of Links and Topics to the Listables (colored blue) represent the has a ItemsViewrelationship from Items to Topics and from Items to Links.

Thus, the database has captured all the object relationships, but has translated it into relational terms.

The next step is to use the Entity Frameworks to translate back to objects, and WCF RIA Services to create those objects both on the database server and on the Silverlight client.

Adding Data to the Tables

For what follows, assume I have the following videos, topics and links:

Assume I have a set of videos in this relationship

Set – 0 Items:

  • Item – Hypervideo Overview (video)
  • Item- Items and Links (video)

Topics for HyperVideo Overview:

  • Topics and Links
  • Multiple Items
  • Clicking a Link

Links for HyperVideo Overview:

  • Silverlight: Get started
  • Sets
  • MVVM

We will have course have authoring tools for adding this information to the database, but for now let’s add it by hand.

Step 1 – Make an entry for the Set
[sql]– set
insert into Listables (TextToDisplay, ImageSource) values ( ‘ ‘, ‘ ‘)[/sql]
Step 2 – Man entries for the two items

Each entry is in two parts: the “base class” table, Listables, and then the “derived class” Items:
[sql]insert into Listables (TextToDisplay, ImageSource) values (
‘HyperVideo Overview’,
‘http://content1.catalog.video.msn.com/…7928.JPG’)
insert into Items (MyListableID, ItemUri) values
(2,
‘http://msnvidweb….b73822cd9f88.ism’)[/sql]
Step 3 – Enter the Topics for the first item
[sql]insert into Listables (TextToDisplay,ImageSource)
values ( ‘Topics and Links’, ‘ ‘)
insert into Topics(MyListableID,MyItem,Offset)
values (14,13,25)

insert into Listables ( TextToDisplay, ImageSource)
values ( ‘MultipleItems’, ‘ ‘)
insert into Topics(MyListableID,MyItem,Offset)
values (15,13,52)

insert into Listables ( TextToDisplay, ImageSource)
values ( ‘Clicking A Link’, ‘ ‘)
insert into Topics(MyListableID,MyItem,Offset)
values (16,13,85)[/sql]
Note that each of the three topics is entered in two parts, the Listable and the Topic.

Step 4 – Enter the Links for the first item
[sql]insert into Listables ( TextToDisplay, ImageSource)
values ( ‘Silverlight: Get Started’, ‘ ‘)
insert into Links(MyListableID, MyItem, Offset)
values (17,13,37)

insert into Listables ( TextToDisplay, ImageSource)
values ( ‘Sets’, ‘ ‘)
insert into Links(MyListableID, MyItem, Offset)
values (18,13,49)

insert into Listables ( TextToDisplay, ImageSource)
values ( ‘MVVM ‘, ‘ ‘)
insert into Links(MyListableID, MyItem, Offset)
values (19,13,90)[/sql]
We would then enter the topics and links for the first item as well.

Examining the raw data and the relationshiops

When we’re done, we can do some queries to make sure that the data makes sense. First, we’ll examine the Listables table; ListablesResultswe should see the “base” data for the set, for each item and for all the topics and links:

That is, in fact, exactly what we see. Each entry has a unique ID (in this case an integer, in a future release a GUID). Entry 1 is the Set (which has no text or image). Entry 2 is the first Item we entered.

Entries 3-7 are the Listable parts of the Topics for the first item and entries 8-13 are the Listable parts of the Links for the first item.

Note that Listable ID 13 represeents the second item, and that is followed by the Listable parts for the topics and links of the second item.

To see these relationships, we can query the TopicsView to see that the database has captured the Text to display, the offset (in seconds) of where to jump to if a topic is chosen, and the relationship between the Topic entry, its own Listable entry, and the Listable entry for the Item that the topic relates to.
[sql]select TopicsID, MyListableID, TextToDisplay, MyItem, Offset
from TopicsView[/sql]
The result of this query displays 5 columns,

TopicsViewTopicsID is the unique ID for each Topic entry

MyListableID is the ID of the entry in Listable that completes this topic (i.e., the base part of this Topic)

TextToDisplay is the text that will be displayed in the Topics window

MyItem is the ListableID of the item that these topics are for (e.e., Listables 2 and 13 shown above)

Finally, Offset is the number of seconds into the video that clicking on the topic will scrub to.

This work is licensed under a Creative Commons license.
Posted in Mini-Tutorial | Tagged | 1 Comment

When Is It OK To Hack?

MiniTutorialLogo

This mini-tutorial is part of the SLHVP documentation

One of the goals of the Silverlight HyperVideo Project is to demonstrate best practices.  So when is it okay to throw in a quick hack to get things working?

Continue reading →

Posted in Patterns & Skills | Tagged , | 2 Comments