Simplicity is the ultimate sophistication - Leonardo Da Vinci. RSS 2.0 Atom 1.0
# Thursday, June 05, 2008

In the Part 1, I talked about some of the applications you can build for the Zune today, and specifically, my plans to create a wrapper for the Zune user card Web service using LINQ to XML. Note that this is a quick and dirty class I baked in a couple of hours. If you are looking for a more robust implementation, be sure to check out Mehfuz's WebLog - specifically his posting on integrating REST with LINQ to XML, and his custom LINQ.Flickr provider. Let's take a look at the namespaces:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

You'll notice that System.Linq (to access the core LINQ functionality) and System.Xml.Linq (to access LINQ to XML) are included as namespaces. Then a class called ZuneCard is defined and a bunch of public auto-implemented properties are defined (a feature of C# 3.5 - each property corresponds to a node in the Zune Card XML tree):

namespace ZuneCardApi
{
    public class ZuneCard
    {
        // Exposed Properties
        public string id { get; set; }
        public string label { get; set; }
        public string firstName { get; set; }
        public string status { get; set; }
        public string tileBig { get; set; }
        public string tileSmall { get; set; }
        public string name { get; set; }
        public string location { get; set; }
        public string bio { get; set; }
        public string backgroundLarge { get; set; }
        public string backgroundSmall { get; set; }
        public string totalPlays { get; set; }

Then ZuneCard is implemented and the tag parameter is passed (corresponding to the user's Zune tag). The XDocument object is used to load in the XML data for the user card. Note that this operation happens only once, then the data can be manipulated and queried to your heart's content in memory (which has performance benefits).

public ZuneCard(string tag)
 {
     XDocument zCardXml = XDocument.
      Load(@"http://zcards.zune.net/zcard/usercardservice.ashx?zunetag=" + tag);

Next, we need to call our LINQ queries. Essentially, we are transversing the nodes of our XML tree (found here) starting at the user node. Anonymous Types (another C# 3.5 feature) are used liberally here (as you can see below):

var user = from u in zCardXml.Descendants("user")
                  select new
                   { 
                      _id = u.Element("id").Value,
                      _label = u.Element("label").Value,
                      _firstName = u.Element("firstName").Value,
                      _status = u.Element("status").Value,
                      _tileBig = u.Element("image").Value,
                      _tileSmall = u.Element("image").Value
                  };

               var userData = from uD in zCardXml.Descendants("userData")
                  select new
                  {
                      _name = uD.Element("name").Value,
                      _location = uD.Element("location").Value,
                      _bio = uD.Element("bio").Value,
                      _backgroundLarge = uD.Element("image").Value,
                      _backgroundSmall = uD.Element("image").Value,
                      _totalPlays = uD.Element("totalPlays").Value
                  };

Finally, we need to iterate through the collections and load the values into the public properties (as shown below):

        foreach (var u in user)
         {
             id = u._id;
             label = u._label;
             firstName = u._firstName;
             status = u._status;
             tileBig = u._tileBig;
             tileSmall = u._tileSmall;
             }

         foreach (var uD in userData)
         {
            name = uD._name;
            location = uD._location;
            bio = uD._bio;
            backgroundLarge = uD._backgroundLarge;
            backgroundSmall = uD._backgroundSmall;
            totalPlays = uD._totalPlays;
           }
        }
    }
 }

In the next part in the series, we'll take a look at how to handle collections corresponding to playlists, badges and other user preferences. In the meantime, if you have any suggestions on how to improve this code, feel free to post a comment.

Posted at 2008-06-05 03:14 AM by jldavid 
 Permalink |  Comments [0] | Categories: Development | Zune

Comments RSS | Email this | Technorati Links | Digg This! | Save to del.icio.us | Kick It!
# Wednesday, June 04, 2008

                

I'm a big fan of the Zune (I own four of them, believe it or not) - so as a developer, I'm naturally inclined to think about novel ways to write applications for the device. There are several different approaches I've uncovered so far:

In this blog post, I will focus on the before last bullet point - how to create a API wrapper for the Zune Card Web service. To access the Zune user card service, simply point your browser to the following URL (including your Zune Tag - in my case, stormpixel):

http://zcards.zune.net/zcard/usercardservice.ashx?lcid=1033&src=external&zunetag=stormpixel

You'll notice that the Zune Card (zCard) is based on a custom XML schema. The uri provides a link back to the user card service. The id denotes the Zune user id. The firstName, status message and tile images are self-explanatory. The manifest contains additional information about the user, badges, playlists, contact information and preferences:

             

I've created a preliminary API wrapper using LINQ to XML to access the information contained in the Zune cards. To access information about a Zune card, you can instantiate a variable of type "ZuneCard", passing into it the zune tag of the user. Once the object has been instantiated, you can then pull in user properties and collections (deserialized for your convenience). The example below is a console application where I'm querying the ID for the user stormpixel:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DisplayZuneCard
{
    class Program
    {
        static void Main(string[] args)
        {
            ZuneCard zuneCard = new ZuneCard("stormpixel");
            Console.WriteLine(zuneCard.id);
            Console.ReadLine();
        }
    }
}

If I run the application, I get the console window shown below. In the next blog post, I'll explain in more detail how I implemented the API.

Posted at 2008-06-04 06:56 AM by jldavid 
 Permalink |  Comments [0] | Categories: Development | Zune

Comments RSS | Email this | Technorati Links | Digg This! | Save to del.icio.us | Kick It!
# Monday, June 02, 2008

You can get a lot of perspective on where we are at in terms of cloud computing and storage if you take a look at a specific domain, such as photography. Not so long ago, I was completely relying on film based cameras. I would take a bunch of photos and get them developed. The whole process was so highly unreliable. If the lighting was bad or the image was blurry - too bad. I wouldn't know until I got the pictures back from Blacks' or some other photo finishing place. Took about an hour to print (at a premium). You also have to buy albums to store your "physical media" - film and photos.

Old school film-based cameras are still around - but getting harder to find (you can still buy disposable cameras that has film in it, some professional photographers still use film, and so forth).

Fast forward to today - my first digital camera was an HP PhotoSmart 735 (not a great camera by any stretch, but did a satisfactory job). I now use a Nikon Coolpix S50C and I've suddenly become a decent amateur photographer. I can preview the photos I take on a nice LCD screen and get instant feedback on the quality of my shots (my style has evolved to iterative, agile photography instead of waterfall).

Once you go into a digital direction, you soon get faced with the problem of massive amounts of data - how do you store and manage it? My preliminary solution was to burn CD-Recordable discs. But again, there is a reliance on physical media. What if the disc has a scratch on it and is unreadable? What if my house burns down? An extreme circumstance - but it can happen.

I solved the problem by moving my photos up on Flickr. Now my entire extended family and friends can access them (in fact, my pics have been viewed over 16,703 times), I can upload them through the website or using a client (Flickr Uploadr). I currently have 2,486 photos online. If you estimate that each photo is approximately 1.44 MB in size, that totals about 3.5 GB of storage. I don't have to worry about storing them on physical media and creating backups in several locations (in case of floods or house fires). I can access them from anywhere - and I can keep my photos up to date very easily. In my household, cloud computing has arrived. My camera even supports wifi and will automatically upload my photos online (although I haven't explored that feature yet).

Live Mesh is looking very promising in providing similar capabilities for the desktop, you can sync up files and access them in an online version of your desktop or on multiple computers. I've been testing it out - it has a wonderful potential to provide the same benefits I'm getting with photos through Flickr. Instead of using USB keys, I'm finding myself using Windows Live SkyDrive more often than not for sharing files.

As a developer, I'm getting quite excited about the prospect of storage and reliability capabilities in my applications. Ubiquitous data rocks - I can create a Web, desktop and mobile application that shares the same data store and membership capabilities. No need to worry about the plumbing involved in synchronizing data across these different application platforms! How has cloud computing affected you?

Posted at 2008-06-02 09:33 AM by jldavid 
 Permalink |  Comments [0] | Categories: Development | Personal | Software

Comments RSS | Email this | Technorati Links | Digg This! | Save to del.icio.us | Kick It!
# Friday, May 30, 2008

Yesterday, Joel Semeniuk asked if I could dig up a list of resources showing the business momentum of Agile methodologies. I was able to pull three core resources off the web, most notably on SlideShare.com (note: if you ever need to deliver a presentation in front of a group of people, check out the website. It has two great features in my opinion - a search bar to find presentations based on the text contained within, and an option to download .ppt files). Here they are:

http://www.slideshare.net/melnik/empirical-evidence-of-agile-methods-190997/
http://www.slideshare.net/sgreene/salesforcecom-agile-transformation-agile-2007-conference
http://www.infoq.com/articles/agile-alliance-survey-2006;jsessionid=7F263F7EC87B20F4F440448A732B6FC0
http://www.agilemodeling.com/essays/proof.htm

The best one out of the pack was delivered by Grigori Melnik (from the Microsoft Patterns and Practices group) - he spoke recently at the Patterns and Practices Summit in Quebec. Here are some of the facts that stood out:

  • Growth of Agile in Banking (Lloyds), Transportation (CP Rail) and Communication (Telus) sectors (from a 2005 study) 
  • From a Melnik/Maurer study in 2005, Agile as a methodology provides a job satisfaction rate of 29.4% (as opposed to 9.9% non-Agile)
  • From a 2007 study, of 1700 people polled, 37% adopted Scrum (followed closely by 23% - Scrum/XP hybrid)

Rather than repeat what's on the slides - here is an interactive version of the deck to check out:

 

Posted at 2008-05-30 04:17 PM by jldavid 
 Permalink |  Comments [0] | Categories: Development | Process

Comments RSS | Email this | Technorati Links | Digg This! | Save to del.icio.us | Kick It!
Archive
<January 2009>
SunMonTueWedThuFriSat
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.


Statistics
Total Posts: 11
This Year: 0
This Month: 0
This Week: 0
Comments: 1
All Content Copyright © 2009 - JL David
Sign In