iPad is Ender’s Desk or Its Precursor

I love Orson Scott Card’s books. My first and still all time favorite is Ender’s Game.

If you’re not a fan, go read the book anyway. If you are, you already know what I’m talking about. The iPad is Ender’s desk, or perhaps its precursor.

Here’s a composite I just made thinking of this concept. One image from Apple and the other from a very innovative early childhood education software company called Imagine Learning.


I’ve never wanted to own an Apple produce product (slip of the finger, but an apple is a fruit after all) or develop software for it until now.

When I think of the amazing ways that educational content and interactivity could be delivered to students using this device, I get very excited. And I imagine a very smart kid hacking the device and sending rude messages to another student. That makes me more excited for the future of technology than anything I’ve seen lately.

Silverlight 4 Enterprise Stack: WCF RIA Services, MVVM and MEF

The .NET technology map keeps expanding, but I have my eye on one particular continent, a little piece of the .NET 4 world I’m calling the Silverlight 4 Enterprise Stack. There seems to be focus coalescing on this important piece of technology real estate.

The Patterns & Practices team blog has a great post looking into the enterprise crystal ball. Be sure to check out their Prism (Composite Application Guidance) on CodePlex.

The primary pieces of the Silverlight 4 Enterprise Stack are:

Other supporting players in the stack are:

With the eminent release of these technologies on April 12, we the Enterprise Software rank and file have much to look forward to in terms of new toys to play with while delivering some amazing new user experiences in the enterprise world.

If you want to keep tabs on the Silverlight 4 Enterprise Stack, be sure to set your RSS reader to tap into these key bloggers:

For us enterprise software geeks, the year 2010 is shaping up to be a very good year!

WCF Plugin Architecture for .NET Windows Service with Easy Debug Console Mode

I've been wanting a simplified WCF plugin architecture for .NET Windows service with easy debug console mode to make my life easier. Building services with Windows Communication Foundation (WCF) is simple and hard. The service and data contract code is simple, like this:

namespace Test2Common	
  public interface IMyOtherService
    [OperationContract, FaultContract(typeof(WcfServiceFault))]
    string GetName(string seed);

    [OperationContract, FaultContract(typeof(WcfServiceFault))]
    Person GetPerson(int id);

  public class Person
    public string Name { get; set; }

    public string Title { get; set; }

But that is where simple ends. The hosting and client proxy code and the configuration XML (or code) is not simple. Even when I use tools to generate these artifacts, I find myself having to tweak and fix and delve deeper than time permits. And since I prefer simple, I decided to create a reusable framework for hosting my limited scope services. Here's what I wanted (download PluggableWcfServiceHost.zip (38.05 KB)):

  • Fast net.tcp binding
  • Windows credentials and authentication
  • Encrypted and signed transport (no packet sniffing allowed)
  • Simplified configuration (hide everything I don't want to see)
  • Windows Service host that behaves like a Console app when I'm debugging
  • Dynamic loading of the service (no changes to the host code to add a new service)
  • Generic client so I don't have to write or generate proxy code
  • Client that is truly IDisposable (hide Abort vs Close for me)
  • Long timeout in DEBUG mode so I can really take my time while debugging
  • Inclusion of exception details in DEBUG mode only
  • Base service class with a simple Authorize method to support multiple Windows groups
  • Support for multiple Windows group authorization
  • Identical configuration for server and client
  • Cached resolution of service plugin service and contract types
  • Minimal number of assemblies (projects) in the solution
  • Keep the implementation of the service hidden from the client
  • (Probably some I've forgotten to mention)

Here's the simplified config with two services configured:

<?xml version="1.0" encoding="utf-8" ?>
    <section name="wcfServices" 
          type="WcfServiceCommon.WcfServiceConfigurationSection, WcfServiceCommon" />
  <wcfServices consoleMode="On">
      <add key="test1"
          hostType="Test1Service.ThatOneService, Test1Service"
          contractType="Test1Common.IThatOneService, Test1Common" />
      <add key="test2"
          hostType="Test2Service.MyOtherService, Test2Service"
          contractType="Test2Common.IMyOtherService, Test2Common" />

And here's the implementation of the service (It really is simple):

namespace Test2Service
  public class MyOtherService : WcfServiceBase, IMyOtherService
    public string GetName(string seed)
      return "This is my name: " + seed.ToUpper();

    public Person GetPerson(int id)
      return new Person { Name = "Donald Trumpet", Title = "King of the Hill" };

Now for the really fun part. The client. Hey, where's the proxy? Hidden away just like it ought to be.

namespace WcfSvcTest
  class Program
    static void Main(string[] args)
      using (var client1 = WcfServiceClient<IThatOneService>.Create("test1"))
        var add = client1.Instance.GetAddress(8);
        Console.WriteLine("{0}", add.City);

      using (var client2 = WcfServiceClient<IMyOtherService>.Create("test2"))
          var per = client2.Instance.GetPerson(7);
          Console.WriteLine("{0}, {1}", per.Name, per.Title);
        catch (FaultException<WcfServiceFault> fault)
        catch (Exception e) //handles exceptions not in wcf communication


To save space, I only wrapped the use of the client in try catch on the second test service.

Note: You have to remember that the WcfServiceHost requires the "common" and the "service" assemblies of your dynamically loaded services in it's bin folder. The client (see WcfSvcTest project in the solution) will also need a copy of the "common" assemblies in it's bin folder. You'll find I'm doing that for the test using post-build commands (copy $(TargetPath) $(SolutionDir)WcfServiceHost\bin\debug\). And of course, both need to have identical config sections as shown in the code.

I hope you find this WCF plugin architecture and the accompanying code useful. I will certainly be using it. If you do use it, please let me know how it goes.

Download PluggableWcfServiceHost.zip (38.05 KB)

User Experience Principles for Developers

Let’s face it. Most of us code slingers have no innate understanding of what makes a great user experience (UX) design. We spend so many hours in front of multiple user interfaces that navigating and using software becomes virtually intuitive, instinctual. But we are not “normal” users.

I’ve just finished reading and mean to re-read Whitney Hess’s “25 Guiding Principles for UX Designers” on Inside Tech. It’s a great piece with some very good references. I recommend you read the entire article multiple times. Here are some of my favorites (my number is not the same as Whitney’s):

1. Understand the underlying problem before attempting to solve it.
How often do we just begin coding and throwing a user interface together without having spent much, if any, time with the target audience to understand their needs, challenges, skill level and approach to solving the problem currently?

2. Make things simple.
How often do we try to put every feature we can pack into a single view thinking to make the software powerful and reduce round trips to the server or some other resource?

3. Provide context.
How often do we place controls or information in a user interface that we consider convenient but in reality is out of context and will confuse a user who does not understand what is going on “under the covers” so to speak?

4. Be consistent.
How often do we design one page in a certain way only to bounce the user to another page in a web application that uses a different design paradigm, making the user spend some time just to figure out where the OK or Cancel button or link is now?

You can read about these and the 21 principles at Whitney’s article (see link above). I also recommend the following resources, a selection from those Whitney recommends:

UX Principles and Design Guides

If you have some favorite principles of your own, please share them here.

Why The Software (or Any) Team Fails

I’ve been giving the question of why software teams fail some considerable thought in the past few days. Reading Brad Abrams’ post Don’t Waste Keystrokes and his statement that “By far the biggest problem I see on teams of > 1 is communication” led me to compile the following list. Here are some of the reasons, in addition to the most important one that Brad pointed out already, that a software team, or any team really, fails:

  1. The team does not practice regularly, no coordinated learning.
  2. The coach does not know the strengths and weaknesses of the players.
  3. The players do not know their role, their zone or the plays.
  4. The players do not get along, they are not one in purpose.
  5. The players do not trust or respect the coaching staff.
  6. The coaching staff puts players with no skill on the starting lineup for unknown reasons causing resentment amongst the other players and guaranteeing a loss at game time.
  7. The players do not believe the coaching staff understand the game.
  8. The players are more focused on individual agendas, they do not work together to win.
  9. The rules of the game are not well understood and change during the game.
  10. The coaching staff and team captains disagree on how the game should be played.
  11. The coaching staff recruits new players looking for players who will agree with their ideas rather than seeking out players who can actually play.
  12. The players fail to improve their skills on their own time.
  13. The players lack motivation and fail to come to practice and give only a half-hearted effort in the game.
  14. The team captain spends more time arguing with the coaching staff than he does leading and motivating the players.
  15. Winning becomes secondary to just finishing the season.

If you can think of any others, please let me know. And if you have ideas for how to fix these situations, I would love to hear from you as well.

Keyword Extraction in C# with Word Co-occurrence Algorithm

A few years ago I worked on a project called Atrax which among other things included an implementation of the work of Yutaka Matsuo of the National Institute of Advanced Industrial Science and Technology in Tokyo and by Mitsuru Ishizuka of the University of Tokyo.

I decided to revisit the keyword extraction algorithm and update it a bit and isolate it from the overall Atrax code to make it easier for anyone to use. You can download the code Keyword.zip (17.87 KB).

Here are the top ten keywords the code returns from the Gettysburg Address and from Scot Gu’s most recent blog post:

   people people

   VS 2010 and Visual Web Developer
   ASP.NET 3.5
   Web Developer 2008 Express
   VS 2010
   VS 2008
   Improved Visual Studio

Let me know if you end up using the implementation of the algorithm and if you happen to make improvements to it.

Keyword.zip (17.9KB) - updated link

ASP.NET MVC 2 MinStringLength Custom Validation Attribute

I love ASP.NET MVC 2 validations for client and server via annotations. Steve Sanderson's xVal is great too, but in this post I want to focus on a custom validation for MVC 2 which is frustratingly missing from the out-of-the-box validations. There is a very nice StringLengthAttribute which allows you to specify a maximum length but does not provide for a minimum length.

At first I attacked this deficiency with a regex like this:

[RegularExpression("[\\S]{6,}", ErrorMessage = "Must be at least 6 characters.")]
public string Password { get; set; }

This approach just seems clunky. Happily, while reading Scott Allen's piece on MVC 2 validation in MSDN magazine, I came across a critical reference to one of Phil Haack's blog posts which I must have overlooked.

Thanks go to Phil's easy to follow instructions on writing a custom validator for MVC 2 that will work on both client and server sides.

So here's my custom MinStringLengthAttribute and supporting code which let's me do something easier and cleaner like this:

[StringLength(128, ErrorMessage = "Must be under 128 characters.")]
[MinStringLength(3, ErrorMessage = "Must be at least 3 characters.")]
public string PasswordAnswer { get; set; }

If you really wanted to get creative, you could produce a combination of the two, but I'll leave that for another day.

Here's the code for the attribute and the required validator:

public class MinStringLengthAttribute : ValidationAttribute
  public int MinLength { get; set; }

  public MinStringLengthAttribute(int minLength)
    MinLength = minLength;

  public override bool IsValid(object value)
    if (null == value) return true;     //not a required validator
    var len = value.ToString().Length;
    if (len < MinLength)
      return false;
      return true;

public class MinStringLengthValidator : DataAnnotationsModelValidator<MinStringLengthAttribute>
  int minLength;
  string message;

  public MinStringLengthValidator(ModelMetadata metadata, ControllerContext context, MinStringLengthAttribute attribute)
    : base(metadata, context, attribute)
    minLength = attribute.MinLength;
    message = attribute.ErrorMessage;

  public override IEnumerable<ModelClientValidationRule> GetClientValidationRules()
    var rule = new ModelClientValidationRule
      ErrorMessage = message,
      ValidationType = "minlen"
    rule.ValidationParameters.Add("min", minLength);
    return new[] { rule };

Here's the code in the Global.asax.cs that registers the validator:

protected void Application_Start()
  DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(MinStringLengthAttribute), typeof(MinStringLengthValidator));

Here's the javascript to hook up the client side:

Sys.Mvc.ValidatorRegistry.validators["minlen"] = function(rule) {
  var minLen = rule.ValidationParameters["min"];

  //return validator function
  return function(value, context) {
    if (value.length < minLen) 
      return rule.ErrorMessage;
      return true;  /* success */

Now, in your view, add <% Html.EnableClientValidation(); %> and that's all there is to it.