Thursday, April 25, 2013

Brandon Saad deserves to win the NHL Rookie of the Year

The Calder Memorial Trophy is the annual award given to the NHL Rookie of the Year.  It has a long history of illustrious winners including Alexander Ovechkin (over Sidney Crosby in 2006), Evgeni Malkin, Brandon’s teammate Patrick Kane and others. 

This shortened NHL season has seen a strong crop of potential candidates for the award.  While you can find out more information on those candidates, if I had a vote it would go to Blackhawks starting Left Winger, Brandon Saad. 

Why?  While Brandon stats speak for themselves: He's fourth on the Blackhawks in goals (10), fourth in assists (16), tied for fifth in plus/minus (+16).  He’s only committed 6 penalties all season long.  Sydney Crosby has committed 1 more penalty in 36 games compared to Brandon’s 45. 

Brandon’s stats against other rookies are even better.  He’s 5th in goals (only 4 behind #1), 2nd in assists (1 behind), 3rd in points (2 behind) and 1st in plus/minus.  

Brandon’s success doesn’t stop there.  He plays on the #1 line across Jonathon Toews and Marian Hossa on the #1 team in the NHL, the Blackhawks already won the President’s Trophy for most points in a season.  He’s played there since game 1 and hasn’t lost his position.

For those who don’t play, watch or coach hockey my last paragraph wouldn’t make much sense.  Let me take a moment to explain why “the last” paragraph alone should merit the award.  When you play on the #1 line on the #1 team, you face every other teams “very best” players.  You play against their elite defenseman, their shutdown forwards and the other teams #1 scoring line. 

No coach in their right mind would put a rookie on the top line unless he whole-heartedly deserved to be there.  Not only has Brandon earned his spot, he kept it, excelled at it and continues to be one the reasons the Blackhawks are the #1 team.  Coaches are paid to win games.  Hockey owners are notorious for firing coaches for sneezing in the wrong direction, there's no room for experiments or error. 

When you put together your #1 line, you place your best players on that line.  Chicago has a ton of elite talent.  In addition to the #1 line, the roster has incredible forwards which include Patrick Kane, Viktor Stalberg, Bolland, Sharp to name a few.  Through all of this, Brandon still plays on the #1 line. 

My final comment on why Brandon Saad should win the Calder Trophy lies in the how the season’s progressed.  Those who follow hockey know that every NHL player will tend to play their best hockey and give 110% towards the end of the season.  The NHL Playoffs can end up being equivalent to 25% of the regular season and with 16 out of the 30 teams making the playoffs, the end rush is generally what matters. 

Brandon has faced his opponents #1 talent during this mad rush to the end, while those players are playing their best.  Through all that, he’s had a monster March with 15 points in 14 games.  Look at the other Rookie of the Year candidates.  Their numbers have dwindled, some plummeted, in March and April. 

There’s a lot of reasons why Brandon Saad deserves to be Rookie of the Year.  But when the game’s on the line and the season’s accolades are at stake, the Blackhawks kept Brandon at the tip of the spear and he delivered against the NHL's elite talent.  None of the other rookies can say that.

Tuesday, April 16, 2013

Windows 8 WiFi connectivity issues

Read on if you are struggling with Windows 8 connectivity, here’s my story as to how I fixed mine.

I’ve been playing around with Windows 8 since its first public release.  While I was getting used to its schizophrenic (Metro and traditional desktop) interfaces, I noticed issues with my PC getting ‘Limited’ wireless connectivity.  In addition to the limited connectivity issue, I started experiencing recurring USB, Bluetooth, Outlook (svchost.exe) and other connectivity problems.

Recently, it got so bad that I had to start intentionally blue screening my PC to free up the corrupt processes that were causing these issues to arise.  Stopping and starting services, disabling and enabling devices and other tricks were employed to have it maintain connectivity.

Soon after that, Microsoft acknowledged and put out a fix for the ‘Limited’ connectivity problem.  As soon as I could download it, I did.  I noticed all my Bluetooth issues disappeared.  To my chagrin, my wireless issues got worse.  Before the fix, I could connect to wireless networks 30% of the time.  Now it failed every time. 

The svchost.exe process got worse and my PC became unusable until I went through my routine of disabling, enabling the devices and processes.  I’ve proceeded back to the Internet and the forums and started going through these steps below. 
  1. Turned on "Download over metered connections"
  2. Turned off all power management that I could find
  3. Set maximum performance on wireless adapter in power settings
  4. Ran through the network troubleshooter
  5. WLAN Autoconfig is set to automatic
  6. Verified that I have the latest drivers
  7. I changed the driver from Microsoft to the manufacturer
  8. Ran netsch winsock and netsch int ip
  9. Disabled IP Helper
  10. Disabled suspect applications in Task Manager’s Startup

In a stroke of luck, I read one article where a user uninstalled his corporate VPN client and it freed up his PC.  At this point, I had nothing else to lose.  I uninstalled the VPN client I had on my PC, rebooted and noticed that the wireless connected…automatically.  I went to Device Manager and saw that all the devices that failed to load, successfully loaded. 

I was shocked. 

I rebooted, put the PC in sleep mode, restarted and it worked every time!  My PC feels like a brand new computer now.  Everything runs smoother and performs without a hitch. 

Hopefully this article will help some other people experiencing the same problem.  I was confident that MS had fixed the WiFi issue and my problem was environmental.  For the first time ever, I’m able to use Win 8 as it was meant to be, an ultra-fast, ultra-responsive and rich OS that lives up to the billing. 

Tuesday, April 9, 2013

Create Beautiful Dynamic UI’s using DataTemplates and MVVM

In yesterday’s post, I talked about MVVM and how easy it is to start building composite applications leveraging this innovative programming paradigm.  Until today, I was struggling with linking dynamically created UI elements to the view-model.  To take it one step further, I wanted the user interface to be bound fully (Two-Way) to the view-model and be automatically updated as the view-model changes.

What’s an example?  You have a view that prompts the user to input a count.  That count could be used to create Albums, Contacts or whatever ‘class’ you want.  Here’s the sample code for an Album.cs file:

public class Album
public string Artist { get; set; }
       public string Name { get; set; }
       public string Year { get; set; }

You can add this code to your view-model class:

private ObservableCollection<Album> albums = new ObservableCollection<Album>();
public ObservableCollection<Album> Albums
              return albums;
              albums = value;

Update your view code with the XAML below, link your DataContext to your view-model and as you add new Album objects to your Albums observable collection, they will automatically show up on your UI and be bound to the view-model.  Yes, it’s that simple to build rich UIs that are managed by user input at runtime.

<ListBox Width="510" ItemsSource="{Binding Path=Albums, Mode=TwoWay}" HorizontalContentAlignment="Stretch" BorderThickness="0">
       <StackPanel Orientation="Vertical">
         <StackPanel Orientation="Horizontal" Margin="0,5,0,0">
           <TextBlock Text="Artist:" Width="60" VerticalAlignment="Center"/>
           <TextBox Text="{Binding Path=Artist}" Width="100"/>
           <TextBlock Text="Name:" Width="60" Margin="5,0,0,0" VerticalAlignment="Center"/>
           <TextBox Text="{Binding Path=Name}" Width="210" />
           <TextBlock Text="Date:" Width="60" Margin="5,0,0,0" VerticalAlignment="Center"/>
           <TextBox Text="{Binding Path=Date}" Width="50" />  <!--Normally a date/year picker would be here-->

Monday, April 8, 2013

Demystifying MVVM (Model View View-Model)

If are new to programming or haven’t used modern design and development patterns, MVVM could be a confusing acronym that makes no sense to you.  If you are familiar with legacy design patterns (like MVC and MVP), the model view view-model may look a bit weird, although you’ll find it to be an excellent evolution to your current programming paradigm. 

In layman’s terms the three areas are broken down with these definitions:
  1. Model – The data, typically coming from a database, web service, file, or other source
  2. View – The graphic user interface, such as a windows form or web screen
  3. View Model – An abstraction layer that manipulates the data (model) so the screen (view) can display it.  The view model will include other actions (methods/functions) that can save, edit and persist data.

The real power behind MVVM is the view model.  The view model has OnPropertyChanged events that notify the listeners that data has changed and you should refresh your UI.  Most view models are based upon a ViewModelBase class that has event handlers that are subscribed to and other methods that manage the low level state of the view model.  I included a code snippet at the end of the article that I used in all my projects.

The view model is so powerful, you can reach the point where you have no code behind your view.  You can have the view code (HTML, XAML, etc.), your view model (which can handle button click events, data bindings and data events like inserts, updates and selects) and your model.  You can build test driven software that validates your assumptions and requirements without having a working application.

You can serve up mobile applications, web and thick client from the same infrastructure.  The end result can be limitless.  You can support iPhones, Android, Ubuntu, UNIX and Windows clients.  Your development time can be dramatically reduced and your quality can be increased as well. 

The best part there’s so many different programming technologies that support it.  WPF and Silverlight inherently support it.  JavaScript has a library known as Knockout that implements MVVM.  You can leverage the Razor engine, standard ASP.NET, Ruby and so much more. 

Look at MVVM and you’ll find a new paradigm in programming that’s easy, powerful and efficient.  The best part, it’s light and doesn’t require a lot of infrastructure to make it work. 

public class ViewModelBase : INotifyPropertyChanged
/// <summary>
/// Set the ViewModelBase to throw exceptions when property names are invalid
/// </summary>
private bool throwOnInvalidPropertyName = true;

/// <summary>
/// Expose a property to override the base value
/// </summary>
protected bool ThrowOnInvalidPropertyName
                     return throwOnInvalidPropertyName;
                     throwOnInvalidPropertyName = value;
/// <summary>
/// Setup an event to handle property changes
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// Verifies if the property is valid and raises an event that its changed
/// </summary>
/// <param name="propertyName">Property that's changed</param>
protected virtual void OnPropertyChanged(string propertyName)
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
PropertyChangedEventArgs e = new PropertyChangedEventArgs(propertyName);
       handler(this, e);
/// <summary>
/// Verify that the property name matches a real, public, instance property on this object
/// </summary>
/// <param name="propertyName">Property to check</param>
public void VerifyPropertyName(string propertyName)
            if (TypeDescriptor.GetProperties(this)[propertyName] == null)
                       string message = "Invalid property name: " + propertyName;
if (ThrowOnInvalidPropertyName)
throw new Exception(message);

Thursday, April 4, 2013

Is Silverlight development dead? Far from it!

Silverlight started out as a boutique development toolkit that originally only supported JavaScript with vector based graphics.  It was Microsoft’s attempt at stemming the Adobe Flash tide that was sweeping the web world. 

Originally launched in 2007, it was Microsoft’s first foray into a platform independent software application.  Soon it grew in popularity and over the course of the next 5 years, reached approximately 2/3 market penetration of internet users.  With support for various browsers and the Mono implementation on Linux, Silverlight expanded its reach further into the world of computers more than any other MS tech. 

During this time, the use of smart phones and ultimately tablets took a major foothold in the market.  Battery life and enabling these devices to work through a day without a charge became a struggle.  Plug-in based controls like Silverlight and Flash became taboo.  They consumed a lot of CPU resources and thus reduced battery life. 

I won’t pretend to be an expert on the subject, but something tells me that software running in a plug-in environment can’t possibly be worse than HTML5 canvas or OGG video.  Open your browser, go to your favorite website and see the memory footprint of your browser.  I bet it’s over 100 MB.  So much for thin client applications…

As I digress, Silverlight 5 appeared to be the last version of this really compelling software stack.  Silverlight 6 still hasn’t shown up in any MS document or road map and most likely it won’t.  Windows 8 ‘Metro’ IE browser doesn’t support it.  Mainly because it’s 64-bit and Silverlight was never ported to be run in a 64-bit browser.  Interestingly, Microsoft just extended support for Flash in the Metro browser in a recent update.

I’ve written, implemented and brought to market over a decade’s worth of web applications.  I’ve used many of the innovative technologies under the sun.  I’ve seen the future with HTML5, CSS and JavaScript and let me tell you it isn’t as rosy as people make it out to be. 

Building business applications can be very tedious and the performance can be horrible.  Like its predecessors, HTML5 lacks standard controls (data grid anyone) and use of real object-oriented programming is missing in this new wave of programming.  Even using the venerable MVC development pattern is taking 5 steps back compared to MVVM. 

Sure you have portability across iPhone, Android, tablets, WinPh8 and so on.  What you gain in flexibility you lose in programming speed and features.  Sure you can build anything you want and given the amount of time it takes it may not end up being that feasible.  I’m not convinced that HTML5 is the answer.  With no Silverlight 6 coming, it appears that this dynamic, rich development toolkit will go the way of the dinosaurs. 

Well not so fast.  You see Silverlight happens to be the primary technology used in Windows Phone 8.  In fact, ‘Metro’ based applications leverages Silverlight like technologies in a hybrid WPF kind of way.  Microsoft hasn’t given up on this amazing technology, they’ve adapted it.  They are using it to meet new and emerging needs.  In areas that could really use it. 

While I’d love to see Silverlight 6 come to market and be supported in Windows 8 Blue and on the iPad.  In lieu of that, I’m confident that this amazing technology stack will continue to evolve and meet new and challenging needs going forward.