How my 12-yr-old son became a C# Programmer

My 12-year old son has been scripting since he was 7 or 8 and writing C# code for about 2 years now. Now for full disclosure, both my husband and I are software developers; my husband writes C++ and Java on the Linux platform but was a long-time Windows developer while I’m a C# .Net developer. We’d thought of eventually showing our son how to program but hadn’t planned on getting him started before he’d even learned long division.

The scripting was a bit of an accident. The PC game my son loved to play came with a full-featured game extension tool for users to develop their own modules and quests. Also included was the ability to write scripts to supplement the existing library with new functionality. It’s always exciting to invent your own modules and see how far you can push the envelope so this quickly became his favourite occupation.

The Copy-Paste Era

At first, his father provided him with a few key scripts that he could hook up to strategic locations and that would trigger a particular behaviour. For example, a “teleporter” script could be hooked up to a particular square in the game. When a character stepped onto the square, they would be “magically” transported elsewhere. But as any parent knows, children have many more hours for play than we parents have for fulfilling all their requests. Tired of waiting for daddy to have free time to write more scripts, my son begged for access to the scripting tool and started copying the scripts he’d already been given and tweaking them to fit the new functionality he wanted. That’s how he realized that programming was fun and not particularly difficult once he understood the logic and the syntax.

The Bounce-Stuff-Around-The-Screen Era

Writing scripts for your favourite game is one thing. But wouldn’t it be even more interesting to write a game of your own from scratch? So father and son sat down together and coded Pong, Asteroids, and other such simple games. At this point, it was mostly my husband coding but explaining what he was doing. This can keep a boy interested only so long and since we’d recently bought an XBox, it made sense to delve into XNA programming next.

My husband bought the wonderfully kid-friendly Learn Programming Now MS XNA Game Studio 3.0 book by Rob Miles (there’s a newer edition out now) and worked through the first few chapters with our son who took to it like a duck to water. Soon, he’d sped through the book and was writing all sorts of games that bounced a lot of objects on the screen.

That kept him occupied for a while but eventually, he realized there was more to the games he liked to play than images moving on a screen. He did not have the words to express what he was looking for but I could tell he wasn’t satisfied with the games he was producing. By then, he could handle simple C# data types, conditional statements and loops and had a basic understanding of classes and inheritance. He also understood XNA sprite batches, timers and the Draw method.

The Era of Enlightenment

I came back from Codemash v2.0.1.2 with the EverCraft Kata Dungeons&Dragons-style game instructions and, on a whim, suggested working on it with him. We’d do it using Red-Green-Refactor Test-Driven Development; an agile technique I’d been introduced to at Codemash and wanted to practice. As a huge D&D fan, I figured it was right down my son’s alley. I wrote the first failing test, he wrote the code to make the test pass and I refactored his code, explaining what I was doing and why. Then we traded places and he wrote a failing test for the functionality I was to implement next.

We spent hours implementing the character class with its hit-points, abilities, and more and by the end of that day, my son’s eyes were shining. Finally, he’d uncovered the missing piece of the puzzle. He now knew how to add substance to his games: that logic that made characters tick and non-visual things happen. We did a few more sessions but that project was abandoned long before we reached the end of the Kata document in favour of the sims-based game he’d been aching to write; the one where a few thing might move on the screen but many of the underlying parameters change as time passes.

And that’s when he started flying solo. Now, I hardly ever see his code but the things he creates have me wondering if I could do half as well.

My learning quest

Early in January, I declared this the “Year of Learning”. The year I would immerse myself in technology and absorb as much as possible in all the areas I don’t yet consider myself knowledgeable enough. This means I have started and will continue to deepen my understanding of various aspects of software development from patterns to new programming language syntax, from modern data stores to effective debugging tools and techniques, from JavaScript and its myriad helper libraries to the intricacies of asynchronous programming.

Strategy Strategy

In order to accomplish this lofty self-improvement goal, I took the plunge and subscribed to PluralSight online training. This amazing library of on-demand videos is now my introductory-level training resource. Apress, O’Reilly and Manning are three great sources for technical books and regularly offer discounts on select eBook titles so I’ll be supplementing the online training with their wares, starting with the small collection of eBooks I purchased in the past year but never got around to reading. These should help flesh out concepts to a higher degree than an online course could ever do. But skills learned and never applied get lost quickly so I’ve also committed to spending more time developing code at home so I could try out interesting techniques and tools I might not otherwise get a chance to use.

How will I measure improvement?

I’ll know I’ve improved when I’m able to read the MSDN Magazine each month without feeling that every article has been written for someone much smarter and knowledgeable than I am.

Measuring Progress

It’s only February and already, I feel I’ve woken up to all sorts of new-to-me concepts and strategies that I can’t wait to put into practice. I must be doing something right!

What next?

Now that I have been at it for almost two months, I’m ready for the next step in the journey and that is to share some of what I’ve learned with others as I go. This is prompting me to dust off my “One Thing I’ve learned Today” series. I’m not aiming to write every day but I’ll post something here as often as I can in the hopes that someday, someone else may find a useful bit of information that will help them along their own journey.

Please join me!

Are you satisfied with the state of your career?

I was chatting with a colleague recently when the topic of satisfaction with the state of our respective careers came up. Both of us are software developers with similar backgrounds, at least a decade and a half of experience behind us, married with families, and reasonably financially comfortable.

His immediate answer to the question of whether he felt he was where he’d wanted to be at this point in his professional life was a resounding yes. Mine was an emphatic no.

Nowhere close.

When he prompted me, I made a desperate attempt to justify my answer but the words I heard myself say lacked conviction. I spoke of the potential I’d repeatedly been assured I had and that I hadn’t lived up to. I spoke of the expectations others had had of me and how I’d consistently come short. Even as I uttered the words, I was painfully aware that my arguments were specious. Rather than explaining why I, personally, wasn’t satisfied with my career’s progress, I was detailing the multitude of ways I felt I’d failed to measure up in the eyes of others. None of my justifications had anything intrinsic to do with me. I had ceased to be a sentient individual to become a mirror for the people who had influenced me in the past.

Putting aside external expectations, I truly do feel I haven’t ticked enough items off the list of accomplishments any self-respecting software professional should have completed midway through their career. So as an exercise, I decided to sit down and attempt to express a new answer; one that placed me in the driver’s seat.

In my early dreams, the ones fuelled by teachers and other influential people, I had envisioned myself at the bleeding edge of technology developing the next greatest thing. I’d be an expert in a particular niche area, contributing to or outright authoring technical books, providing training, and possibly even speaking at the occasional conference.

Delusions of grandeur? Possibly. But I knew I had the potential; I’d been told often enough.

I got married while in university and, within 5 years of my graduation, I was the mother of two children and working a four-day week at a company that specialized in asset management software. Though I could speak with some authority about inventory replenishment algorithms or the impact of two digit years as the end of the millennium loomed, the world was leaving me in the dust. The fastest and brightest minds were eagerly jumping on the internet bandwagon while I was adding functionality to or tweaking what was even then considered legacy code. Already, a large portion of the dream had evaporated.

The next few years found me working my way up to development manager by way of technical lead. I did my best to juggle career and family life but my career lost more often than not till I reached a point where the career simply had to be put on hold. My children needed me at home.

I spent five years as a stay-at-home mother though I took on part-time contract work so I could keep up my programming skills. The strategy worked but this was not a period of professional growth for me. By the time I felt that my children no longer required my presence at home, I was so far behind that I no longer considered myself a senior developer. I eventually found a company willing to take a chance on me and hire me as an intermediate developer. That was three years ago.

I’ve been struggling ever since to catch up and learn as much as I can but I’m still far behind the people I consider my contemporaries.

Am I where I thought I would be? Not even close. Do I regret it? A large part of me believes I’ve done the right thing and is satisfied with what I have accomplished. And yet a small but vocal part of me can’t help but yearn for the future I might have had.

I was recently reading the November/December 2012 issue of The Writer, a magazine about the craft of writing, and found the following advice by author Diana Abu-Jaber: “Don’t worry about other writers’ successes or where you thought you would be or should be by now or the latest disappointments. That’s not a winnable game. Wish everyone well, applaud for their triumphs and work, work, work!”

That’s advice I’ve decided to take to heart. So how happy am I with the state of my career? Taking all factors into consideration, I’m satisfied. Now, off I go play with some of those new fangled tools I keep hearing about but haven’t yet had a chance to try.

What about you? Are you where you thought you might be by now?




File Upload with ASP.Net Web API

I recently had the opportunity to create a new RESTful service for the project I was developing for my employer. As this service would be used internally, it was the perfect opportunity to try a technology that was new to me: ASP.NET Web API.

This new service would enable the caller to upload and download images. This is nothing particularly unique as there are many excellent examples on the web that demonstrate some flavor of this. All these solutions call System.Net.Http.MultipartFormDataStreamProvider to write the image file to disk. In my case, I wanted to store the image binary in a SQL Server table so I used the System.Net.Http.MultipartMemoryStreamProvider class to allow me to read the contents of the request and send the image stream to the method that wrote to the database.

As I was developing with Visual Studio 2010, I could not use the new await functionality.

public Task<IEnumerable<int>> Post()
  if (!Request.Content.IsMimeMultipartContent())
    throw new HttpResponseException(Request.CreateResponse(
	"This request is not properly formatted"));

    var streamProvider = new MultipartMemoryStreamProvider();
    var task = Request.Content.ReadAsMultipartAsync(streamProvider)
	      .ContinueWith<IEnumerable<int>>(t =>
      if (t.IsFaulted || t.IsCanceled)
        throw new HttpResponseException(HttpStatusCode.InternalServerError);

      var addedId = streamProvider.Contents.Select(i =>
        Stream stream = i.ReadAsStreamAsync().Result;                      

        // Insert your own code to deal with the Stream.  
        // In my case, I called my code that wrote the image to 
        // database and returned the image's id in imageId such as below.
        int imageId = DatabaseCode(stream);
        return imageId;
      return addedId;
    return task;
  catch (Exception ex)
    throw new HttpResponseException(Request.CreateResponse(
	"Error: " + ex.Message));

This is a minor tweak to the code from the samples linked above but I thought this might be of use to the next person, or even my future self, who attempts to store images elsewhere than directly to disk as I had to do.

If you found this post helpful or wish to constructively point out improvements, leave me a comment!

Happy coding!