Thursday, 23 May 2013

Session Expiration in ASP.NET MVC

The other day a colleague of mine asked me for some help fixing a bug. The issue was that our web sessions are configured to last 30 minutes and after 30 minutes of inactivity ASP.NET should redirect the user back to the login page (in our case at least), but this was not happening in our latest ASP.NET MVC website. I wandered over to his screen and saw it for myself, it just let the request complete as usual, defying my understanding of how session expiration worked.

So I searched around and found out the following:


In our case the session timeout and the forms authentication timeout are different: sessions timeout at 30 minutes while forms authentication can last much longer. So it seems that what ASP.NET MVC does by default (using the [Authorize] attribute) is to authorize the request coming in because that has not expired yet but a new session is set up for the user. This means that any previous data you had stored is missing which will no doubt affect the functionality of your website.


So how can we solve this? This solution is actually quite simple, a custom authorization attribute can be implemented which can both authorize and check the session. For example let’s assume that your session contains something which you know means that a user is logged in, for instance a user ID; that means you can write something like the following:

| AttributeTargets.Method,
= true,
= true
public class CustomAuthorizeAttribute : AuthorizeAttribute

protected override bool AuthorizeCore(HttpContextBase httpContext)
if (httpContext == null)
throw new ArgumentNullException("httpContext");

// Authenticate the user using Forms Authentication
IPrincipal user = httpContext.User;
if (!user.Identity.IsAuthenticated)
return false;

// Now check that a new session has not been created, if we are missing
// some critical session variables then we assume that the session
// expired and do not allow the request to continue
if (httpContext.Session["UserId"] == null)
return false;

return true;

By applying this custom authorization attribute to your controllers/actions you will now be able to check both forms authentication and session expiration at the same time.

Monday, 29 April 2013

Writing Working Code at Hyperspeed

Image courtesy of Cycling Cosmonaut

Today I thought I would share with you something I had to do recently at work. To give some background I work for Talent Q who are a provider of online psychometric tests; I am one of the developers who works on all the various systems we have such as the candidate tests, the administration side and all sorts of backend services to keep everything working as it should.

In our last sprint we were working on adding a new suite of tests to our product list. In fact we’ve already got them running now as part of some trials before global release and have already witnessed tens of thousands of completions – they clearly work so that’s always a good start! Me and my colleagues did want to go back over the code though before the final release as developers always have that feeling of wanting to perfect their code; we also had a view of making sure long-term maintainability could be achieved.

So we looked through what we had already and found some areas that we wanted to improve. The main part was that the code was trying to be too clever for its own good:

  1. Most classes were trying to be very generic but ended up not incorporating the specifics of each individual test, resulting in some code smells such as lots of object casting which was unnecessary.
  2. We also had several God objects that tried to contain every conceivable detail you could imagine yet at the end of day even missing some vital details.
  3. Due to all the various classes being very generic it was difficult to follow through the logic of the code. There was clearly a design in there to not have too many strong dependencies interlinked with each other – something that I believe is definitely worthwhile – but you could also get easily lost down a codepath; bear in mind that these tests were built up in an organic manner as most things are so the end result does tend to have more than you actually need (which I will discuss later on).

So I was the one tasked with implementing the changes we wanted. We decided that we would not make all these generic types which somehow had to be tied together, instead each test would have a dedicated class with a clear focus even if it meant some duplication of logic – as long as we have working code we would be able to compare the differences and refactor later if required.

All seems reasonable so far. Oh, did I mention that due to a number of planning issues I had to do all of this in a matter of days?

Umm, OK…

But I managed it, all within working hours (no overtime) and it all worked first time! Here’s how I did it…

Plan Your Work First

You might think that with a tight deadline in front of you that you should not waste any time and start writing code immediately, right?


You could do this but without a clear focus on what you are trying to achieve you’ll struggle to keep up with what you are doing; you don’t want to be thinking of what you need to do and how to translate that into code at the same time.

So first of all I spent a few hours going over what I needed to do. I looked at each of the new tests we were creating and wrote down notes to help me understand the high-level logic that drove them, such as:

  • How do I load the questions?
  • How do I keep track of state and where the candidate is in the test?
  • What if the candidate quits a session and restarts from the last question they answered? Will we be able to know where to pick up the test from?
  • How do I get a final result from the test?

Fortunately out of the three new test types we were creating two of them were similar to previous assessments we had already released so it wasn’t too hard to work out the details for them. By the end of this I had a one-page document of notes for each test which explained to me everything they needed to do. With this now written down and not cluttering my mind I could finally get down to writing the code.

Test Driven Development is Your Friend

Now I knew what to do I had to figure out how I was going to get my code written down and make sure it all worked quickly. The trial code we currently had was not designed to be testable; it was all written under the assumption that there would always be a database and always have a user interface driving it, meaning that testing that code was manual, laborious and the feedback loop was painfully slow.

I’m a big fan of Test Driven Development though; the idea of writing lots of little tests to quickly verify that your code is working is something I’ve jumped onto with gusto. In the end, although I don’t particularly like the idea of rewriting code from scratch, I decided that I was going to have to write the code for these assessments from first principles again and this time focus on making them work in an isolated environment meaning no database or website required.

Start Typing

Image originally from Tumblr

With all this in place it was time for me to start typing, and fast! One of the benefits of Test Driven Development is that because unit tests are so small you can clearly focus on one tiny bit at a time. For example if I wrote the constructor for the assessment then under the scenario of a brand new assessment being run I knew that the outcome of creating the object would mean:

  1. The internal state would be set to “Running Test” instead of “Completed”
  2. That the first question number would be one
  3. That the total number of questions available would be a specific number
  4. That the first question was loaded into the test
  5. etc

So I simply wrote one test at a time, used the test runner to make sure it passed, and moved to the next one. I managed to keep up this pace and produce quite a number of test cases quickly, all the while improving the code and verifying that it all worked as I expected it to.

Getting “In the Zone”

My blog is called “In the Coding Zone” as it refers to that mythical place where developers love to roam and simply be lost in their own thoughts without any kind of interruption. When “in the zone” developers are able to churn out vast amounts of code and be hugely productive.

Getting there is a challenge in itself, especially when working in an open office environment. Fortunately I got very few distractions during this time so that I really could just ignore everything around me and focus purely on hitting this deadline.

The End Result

After a lot of hard work I hit that deadline but what else did I have to show for it?

  1. With the code rewritten with testing principles in mind we now had our first ever set of assessments which we could run using test automation. This means we can now verify that these assessments work even without a real database and just using dummy data, or build upon the unit tests to create integration tests using a real bank of questions.
  2. For the first time our assessments finally make sense; figuring out how our assessments worked used to be a daunting task but I realised this is because it was down to the sheer amount of extraneous code that was written, not due to the complexity of the logic itself. Test Driven Development is really good at focusing you on what you need to achieve to get your tests running; once all tests pass then you don’t need to write any more code so your final implementation tends to be very lean and ultimately simpler to understand.
  3. One drawback though is that I was mentally tired after this exercise. Keeping up a relentless pace of writing code/tests almost non-stop for days does take it’s toll on you and you can’t keep it up forever.

Developing software seems to have this aurora of always being delayed and not working until you test it over and over again but I wanted to prove that it is possible to have something work first time (and on time!) as long as you plan your work effectively, focus on the job in hand and basically test as you go, not leaving it as an afterthought.

Thursday, 25 April 2013

Is JavaScript Really So Bad?

I’ve had some pretty strong opinions on JavaScript in the past, most of them negative as a previous post has explained. Having been forced into using it more fully recently on several mini-projects though my rigid opinions on it have softened slightly.

Despite working on web technologies I don’t really consider myself a web developer; I am most comfortable in working on server-side code, usually in C#. So when the time comes when I am faced with HTML, CSS and JavaScript I do tend to get a little overwhelmed; I can be extremely productive in C# but tying server-side code to a front-end interface can take me hours, more likely days, to get an end result that I’m not even that happy with. It is this mindset I think that clouds my judgement with JavaScript; I’m simply not that proficient in using it and don’t continue developing this skillset to allow me to improve.

Part of the problem I think is that I am most familiar with ASP.NET WebForms. When I first started web development proper I worked on WebForms and was able to bypass a lot of issues around learning good HTML/CSS/JavaScript practices because WebForms managed most of the functionality for you; just tie up server controls, set some properties and the final rendered result would somehow magically do what you wanted it to. I still work in WebForms but now I’m trying to get more involved with ASP.NET MVC, both in a professional and recreational sense, but there’s a problem; MVC is an excellent framework but it does less for you than WebForms. You have full control over the HTML you output but now I need to know the finer details that WebForms so successfully hid from me all these years, including even simple things like what happens when a HTML form sends a POST request back to the server.

So given that I’ve been working a bit more on MVC websites recently in various capacities I took the opportunity to try and “reset” my thinking process and try and work with JavaScript as it was intended and not as an afterthought or constant hindrance. Over the past few weeks I’ve now started to form these opinions instead:

Separation of Concerns

Below is a typical example of the kind of webpage I’m most used to seeing:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<title>My webpage</title>
<style type="text/css">
: red;
<script type="text/javascript">
function firstLoad() {
"Hello World!");
<body onload="firstLoad()">
<div class="banner">
<a href="Next.html" style="padding: 10px" onclick="javascript: alert('You clicked me!')">Next page</a>

Yuck! See how it mixes HTML, CSS and JavaScript into one file? Unfortunately this is what I see a lot of and, I’m ashamed to say, even do myself because it is easy to do. But then I’ll run into problems like how to test or debug that JavaScript. Take the example of the hardcoded onclick handler on that anchor tag; it’s a simple example but what if it was something more complicated? How could I test that when I find it doesn’t work like I expected?

So instead I’ve tried to decouple the parts of the webpage into a file each for HTML, CSS and JavaScript as nearly every web developer recommends. From this I’ve found it is now easier to edit and view my work; if I want to change the style of an element I go to my CSS file and not hunt for it in the monolithic file and similarly if I need to make a code change I update the script file and reload.


OK, now I’ve got my code separated from everything else so now I can just focus on the functionality of the page, but how do I do <insert cool fancy feature here>? On it’s own JavaScript doesn’t provide a lot for you. Sure, I can use getElementById() to find various parts of the page but after that do I then write a huge amount of code to do a relatively simple thing? No, I would use one of the bazillion JavaScript frameworks out there. To my mind jQuery is the top framework that everyone thinks of.

I spent about a week of playing around with jQuery and using selectors and effects to manipulate the page, calling back to the server to process some JSON data and so on. As a newbie I did have to search around on the internet quite a bit to figure out how to do some simple things but the advantage of jQuery is that, because it is so prolific, there are tons of resources and samples out there to use.

All in all I now can’t imagine trying to do anything in JavaScript now without using jQuery as it just makes things so much simpler.

JavaScript IntelliSense

I will freely admit that I completely rely on IntelliSense when writing .NET code. Why bother memorising thousands of APIs when a simple list can show you what is available? IntelliSense works brilliantly for statically typed languages but JavaScript is a dynamic language; at any point during execution the floor could potentially be pulled up beneath you and the API you thought was available could be changed. The dynamic nature of JavaScript is definitely a positive in a lot of cases but not when it comes to trying to discover what APIs are available, going back to relying on *shudder* reading documentation.

As it turns out though Visual Studio now has a way of trying to provide IntelliSense some information when writing JavaScript code by including reference comments in your file. These seem to work a little like import statements or C-style #include instructions but instead of pulling in code dependencies it looks for source code commenting and adds that information to IntelliSense. I tried it on jQuery and suddenly I can see everything that jQuery is capable of. Amazing!

Having this in JavaScript is such a big time saver for me because:

  1. It saves round-trips to reading documentation and determining what each function is and what it requires. A simple tooltip which shows what parameters are needed and what they do is a great help to me.
  2. It helps a lot in discovering the APIs. jQuery as an example has lots of functions available but how many? And what do they do? Sometimes just having a simple list of functions available is enough to make you wonder what one does and could end up helping you figure out your solution.

Function Callbacks

And now onto some minor gripes I still have with JavaScript!

One of the little annoyances I’m coming across, especially with jQuery’s constant need of function parameters, is that the syntax for creating a nameless function (or sometimes referred to as a lambda function in other languages) is particularly verbose. Here is what I mean:

$(document).ready(function () {
".tag").each(function (index, element) {
// Do something here

Having to write the word function gets a bit tiring when doing it over and over again – especially as JavaScript can be minified, you would think that you would want something shorter to use. Whereas in C# using LINQ I could write something like this:

var results = list.Where(x => x.Age > 10).Select(x => x.Name);

Notice how this “fat arrow” syntax makes things more concise. It does appear though that this is being included in the ES 6 specification so hopefully I will see this in JavaScript one day, I just wish it was now!

But It’s Still Not Working…

By biggest bug-bear with JavaScript though is still the fact that I can write lots of lovely code and it may still not work and the browser won’t tell me it doesn’t work! Rather than tell me anything useful it will simply ignore anything that won’t work and just silently carry on, leaving me bewildered as to why what I expect to happen doesn’t.

Here is a typical conversation I end up having with my computer:

Me: OK, let’s run this and check my new feature works.


Me: Er, hello? Did you do anything? Nothing has happened.

Computer: Sorry, I can’t find that new function you wrote.

Me: But it’s in my source file right here!

Computer: Well it’s not in my cached version which didn’t update on the last page load.

Me: Oh right, the browser cache. *sigh* Let me clear it and reload.

Computer: Ah, now I see your new function!

Me: Great, but still nothing is happening.

Computer: Well no, I can’t find an element with an ID called “banner”.

Me: Er, that’s meant to be “Banner”. With an uppercase “B”.

Computer: Well if you can’t spell that’s your own fault. *snigger*

Me: *grumble* Fine… *fixes spelling* There, happy now?

Computer: No, now I can’t find your new function. Have you tried clearing your browser cache?

Me: *bangs head on table*

…and so on.

Unfortunately this feedback loop happens all the time with me. Perhaps it will improve with experience but at the moment I do end up getting frustrated that no useful developer information is conveyed to me when something goes wrong.


Overall though I am starting to find JavaScript more useful now. When it is coupled with a powerful framework to assist you and you accept it for what it is and not try and compare it to another language I realise now that you can achieve quite a lot with it. Which is useful as it seems that we’ll all be using JavaScript for a long time to come.

Tuesday, 12 March 2013

Windows 8: Bringing the Desktop Back

In my last post I talked about how I felt Windows 8 had pushed ahead too far into the tablet OS space and left the desktop era trailing behind. In essence there are millions of PCs/devices which are currently capable of running Windows 8 yet are not designed for the brave-new-world interface that is the Modern UI. I did say at the end of that post however that I would suggest ways of improving the situation and this is what this post will be all about.

Disclaimer: I am but a humble software developer expressing my own opinions here. I do not work for Microsoft and definitely have no sway in how Microsoft builds its products. I am also not an expert in operating system design and architecture and cannot vouch for whether anything I say below is technically feasible – consider everything below a “wishlist” of what Windows 8 could be.

This post also contains diagrams and mockups created with my own two hands so they might hurt your eyes – I would strongly suggest some protective eyewear before you continue reading.

Splitting Things Up

Microsoft took a gamble with Windows 8; they wanted it to be the operating system that could be installed on any device/system, small and large. Whereas in the past they tried to shoehorn the behemoth that is Windows onto a smaller form factor – see Windows Mobile for an example – this time they are working the other way around, refining their Modern UI concepts on small devices first and then scaling up to larger systems.

The problem I see with this though is that a full-fledged PC and a tablet are not the same; the “windows” concept works well on a PC and the fullscreen, one-app-at-a-time concept works well on a tablet. But Windows 8 tries to do both at once and then the inconsistencies appear; some apps appear in multiple windows on the desktop while some must take up the entire screen and hide everything else behind it.

Ultimately these two ideologies don’t play well together. Apple, on the other hand, have two operating systems - OS X, their full computer operating system and iOS which is their phone/tablet operating system. Both cater to their target devices by only doing what is appropriate on each device with some room for crossover. It is this idea that I think should have been done for Windows but in this case possibly have one OS for each target device – phone, tablet and PC – all running a core Windows system.

Because Microsoft loves to make beautiful architecture diagrams how about I have a stab at one to demonstrate what I mean:


Please bear in mind that this is not very complete and probably laughable but basically I see things working as:

  1. Defining the Windows Core operating system which would contain everything that every other Windows-branded OS requires at a minimum e.g. the kernel with process multi-tasking, input (including touch), output, networking, graphics and even the new Modern UI stack.
  2. Then have the Windows Phone OS be based off of the Core. This would be the smallest OS provided due to the hardware constraints of a phone device but would build upon the core OS to include phone services e.g. SMS.
  3. Then have the Windows Tablet OS be based off of the Core and build upon it to provide enough for a tablet device. Effectively this would be what the Windows 8 Modern UI would become.
  4. Finally have the Windows Desktop OS be based off of the Core and complete the picture; this would provide the full package of components including legacy Windows support (which phones and tablets do not need).

Note there is already the concept of a “core” operating system – Microsoft developed MinWin to disentangle all the dependencies Windows has on its sub-systems and produce a minimal version of the OS to base everything else on – but this idea would take it further. As a lot of the future of Windows is being tied together it makes sense to me to include all the common components into one core system and then build upon them where it makes sense. This means that the Phone OS can focus on just being a smartphone whilst the full Desktop OS can focus on being the productivity powerhouse it used to be.

I also see nothing wrong with including modern concepts into the core OS such as the Modern UI stack or touch inputs – although desktop PCs today may not make much use of them in the future they certainly could.

So that is how I would split them up, but what would each one look like?

Windows Phone

Image courtesy of CNET UK

This one is simple to define as it already exists. When I first got a Windows Phone 7 device I was actually quite impressed that Microsoft almost nailed the entire thing on the first try – thereby breaking their usual “3rd release is best” cycle. And as someone who has used it for a couple of years now I think it works pretty well when considered it is used for things like phone calls, staying connected to your friends and doing things on-the-go. So my thinking is just leave this one be and that is the Phone OS sorted. Next?

Windows Tablet

Image courtesy of Microsoft

This one is also quite simple as well because this would be what Microsoft has been trying to push onto us since Windows 8 was first shown to the world. Basically the Tablet OS would be the new Start Screen and Modern UI apps - no desktop or legacy at all. However, there are a couple of things I would change to make it the tablet OS it should be.

First of all I think the Charms bar should just be ditched as I don’t see any point to it. I think it is meant to show that every app has the capability of several core concepts – Search, Share, Devices (which I’ve never used so don’t even know what this is for) and Settings. But the problem I see with it is that not every app ever developed has to include these charms as sometimes it just does not make sense. Let’s take the example of a simple calculator app. So how many charms would we need for this to function?

  • Search is useless since there isn’t a lot of content to search for
  • I don’t particularly feel the need to Share my calculations on Facebook
  • I don’t really need to print anything usually so Devices isn’t required
  • Calculators are not that complicated so I can’t see too many Settings being needed either

Which means that this app would not require the Charms bar at all – selecting each charm in turn would result in me being told that this function is not available, something I would have to actually click through to find out.

Instead, why can’t we just resort back to some tried-and-true user experience conventions that have been built up over the past couple of decades? For instance, everyone now knows that a rectangular box with a magnifying glass next to it is a “search box” where you can search for things, so why can’t Modern apps simply use the convention too – it’s not like there is a lack of screen estate in some cases.


The Windows Store app now with a search bar to clearly show that you can search for apps

Likewise every website under the sun now has all sorts of “share” buttons littered over their pages, so we could also have Modern UI apps just add a “Share” button when it is appropriate to do so.

Windows Desktop

Now we get the the crux of this post, sorting out the Desktop. I highlighted a few issues I had with the Windows 8 desktop as it is now and the main issue was that every Modern app must be made fullscreen. Now my idea around this problem is simple: put Modern apps in windows again and let the user organise/resize them to how they want them to be. But it turns out someone else has already thought of this; Stardock are developing software which does just this called ModernMix.

An example of how I think desktop should handle Modern apps and what ModernMix is already capable of. Image courtesy of Stardock

To me this feels like the best fit for the desktop – Microsoft could still deploy the new Modern UI apps which use the newer Windows RT technology but not at the expense of what came before it. Remember, Windows is all about building on what already exists. Users would get better, modern applications without sacrificing their own productivity or choices.

And while we’re still removing things let’s get rid of those pesky “hot-corners”. At the moment if you want to see the Start Screen, switch applications or view the Charms bar then with a mouse you can move the pointer into one of the screen “hot” corners and the appropriate action will pop-up. Except that these hot-corners are annoying – it feels so slow and cumbersome to move the mouse all the way to the end of a screen, wait for something to appear and then click on it, which is why I avoid them like the plague and use keyboard shortcuts instead. Simply put the Start button back – which can trigger the Start Screen if Microsoft insist – and that’s all that is needed really.

So now we’ve removed the dud features of the desktop, how can we progress it forward? For a start if Microsoft are committed to this new Modern UI/UX then they should start updating their apps and control settings to use it. This can allow them to start thinking about how to integrate touch controls to important Windows features ready for the future.

One part of Windows 8 I do really like is the live tiles that animate and show all sorts of live information for each application. How could that be applied to the desktop? Perhaps live tiles could be arranged on the desktop itself like regular desktop icons at the moment – a bit like widgets but at least tiles can be organised better.


A mockup of how Live Tiles could be placed onto the desktop

We Can but Dream…

These are some of my wild musings as to what Windows 8 could have been, though I imagine these will never come to fruition; once something is baked into Windows it stays there and Microsoft seem quite committed now to forging ahead with what they’ve got. I am hoping though that Windows “Blue” will try and address some of the usability issues with the desktop/Modern experience but we shall see.

Wednesday, 27 February 2013

Windows 8: A Tablet OS Stuck in the Desktop Era


It’s been a few months since I upgraded my laptop to Windows 8. At the time Microsoft were letting you purchase the upgrade for around £25 which sounded like a bargain to me – my wife got it even cheaper at £15 due to purchasing a Windows 7 laptop recently. So I dutifully downloaded it, was amazed at how the installer just seemed to work (surely upgrading an OS should be more troublesome than this?) and set about using it for everyday use.

So after a few months of use what is my overall opinion? While I find it perfectly usable I think Microsoft may have been a bit too ambitious trying to convert Windows from a big desktop OS to what is now primarily a tablet OS and the jump between the two is currently too large. Now I’m not saying it is a complete disaster – we’re not at Vista levels at all – as there are still quite a few things that I am happy with but given that my laptop has no touch inputs at all and the entire OS seems hell-bent on pushing these new Modern touch-enabled apps in your face then it leaves a user like me feeling a little left behind in this brave new world.

But first let’s focus on the good parts of Windows 8 before I venture into the “could be better” points.


Windows 8 is fast, very fast sometimes. Whatever Microsoft did to the internals of Windows to make it fast enough on less powerful hardware has also paid dividends on more powerful hardware. A cold boot is faster than Windows 7, waking it up from a sleep state even better (it feels like around 10 – 15 seconds to me) – when I compare it to starting up my Windows 7 PC at work it feels like it takes an age to just get to the login screen now.

Live Tiles and the Start Screen

I own a Windows Phone 7 device so I’ve already grown accustomed to the UI intended for all future Microsoft products. I personally think that the Live Tiles idea is probably one of the simplest, best and, dare I say it, most original ideas that Microsoft has come up with in a long while. Live Tiles act as both a shortcut to start an application but also as a widget which provides live information to you when you just stare at the Start Screen; information changes on it as you watch it to show you your latest emails, latest Facebook/Twitter mentions, photos etc. If you have a good enough set of apps installed your Start Screen can suddenly come alive with all kinds of information and I quite like waking up my laptop in the morning and quickly seeing how many emails I have.

And speaking of the Start Screen I have no problem with it; many people got indignant over the loss of the Start Menu but frankly I haven’t missed it at all. It also comes with some nice bonuses such as being able to uninstall anything straight from the Start Screen, and the search functionality is far better than Windows 7.

Desktop Improvements

Despite the focus clearly being on the Modern UI the existing desktop has seen a few new features too.


The Task Manager is now something I love rather than something I use to kill non-responsive processes. The detailed view can show you the CPU, disk, memory and network usage of every process running which provides you far more information than before. Checking network usage is actually incredibly useful – I had problems recently with the BBC iPlayer and used the Task Manager to confirm whether it was actually downloading anything or not.


The Windows Explorer has also seen some improvements such as a ribbon bar to replace the menus (though collapsed by default, I’m guessing due to all the complaints from various users during the consumer reviews) and much better handling of copy-paste operations such as detailed progress and resolving name conflicts.

OneNote MX


Not a part of Windows 8 per se but I thought I would give this a mention; I love OneNote in Office and the OneNote MX app you can get from the Windows Store is probably one of the best examples of a Modern app I’ve seen yet. It’s not perfect – sometimes feeling a little like a prototype of what Office might become – but the fact that I can write my notes and have them sync to SkyDrive to later check on my phone/work PC makes it a fine example of how Microsoft is starting to think beyond the “single PC” ideology that has been governing Windows for decades, plus it is a great example of what you can achieve in a Modern app.


So there are a few things I am happy with and I wouldn’t want to go back to Windows 7. But having said that there are still quite a few problems with it and they tend to revolve around the sudden shift in focus on making it into an operating system designed for every device imaginable.

Modern Apps

I’m going to make a sweeping generalisation here: nearly all Modern apps suck! OK, maybe that is a bit too harsh so let’s try to break it down as there are several areas to this.

I have no problem with the “Metro”/Modern UI style as I generally quite like the simplicity of it all; on a phone it works quite well, and I imagine a tablet would be the same. But for a widescreen monitor things can tend to look a little sparse with a lot of empty space, particularly since Windows 8 forces all Modern apps to be full-screen. Also it is a style which allows less artistic people (e.g. developers like me) to be able to make something that generally looks quite good and hopefully more consistent with the rest of Windows but this is a double-edged sword; a lot of Modern apps I’ve seen so far are devoted to lists/grids of rectangles with some text in it so they are never that pretty to look at.


This is what my SkyDrive app looks like – pretty sparse and flat wouldn’t you say?

These apps are also the latest in a long line of developer technologies that Microsoft tends to flaunt every few years; this time Windows RT is the latest hotness. As all these Modern apps are basically version 1.0 then it becomes very clear that this is a platform that needs time to grow and develop. Currently many apps I’ve seen can be very basic or at worst buggy. MetroTwit for instance never seems to be able to load my Twitter timeline, something I would have thought quite crucial given what it is designed for; as a result I uninstalled that almost immediately.

The fact that all Modern apps have to run fullscreen may make sense on a tablet where screen estate is limited but I really cannot see the point on a full-blown PC. At my workplace I have two monitors so I would be limited to viewing two apps at once whereas previous Windows versions would allow you to have as many windows open as you wanted and organised however you wanted. I mean, do I really need to devote an entire monitor just to see my Twitter feed? At the moment the Modern apps I do use I have to constantly switch between with Alt-Tab to get anything done.

Touch input is the main draw for Modern apps – but only if your hardware supports it. Using a mouse and keyboard is possible but not the best, in the same way that touch is not ideal for using the Desktop. Given that most new PCs would be supplied with Windows 8 by default now but not necessarily the hardware to use it for it's ultimate potential this becomes even more frustrating.

But probably the biggest problem with Modern apps so far is not related to technology or usability but one simple question: what are they for? Every single Modern app I’ve seen has a very clear focus, which is to act as a frivolous, content-spewing machine; why not check Facebook or Twitter or news or weather or anything that is actually not very important to your life or work. Can you honestly see a line-of-business Modern app existing as things currently stand? I can’t. Given that Microsoft have spent so long trying to keep their enterprise customers happy it seems they have now switched sides rather abruptly and are now too focused on the casual user instead, rather than find a happy medium.

Windows Store

Fine, lets assume that you do find some good Modern apps – that means you need to find and install them somehow, which is where the Windows Store comes in. Except that this is also a terrible Modern app in itself.


Take a look at the screenshot above; what attracts you to getting, or even buying, any apps? Do any of them jump out at you? Of course not, they are all flat squares with possibly a single image and their name, basically an example of where the “Metro”/Modern style fails.

I’m no expert in commercial dynamics but if I went into a store to buy something I would expect to be bombarded with colours, images and banners trying to advertise everything under the sun – what we have here instead is everything hidden away and not showed off to its full potential. There may well be some truly excellent apps hidden away in there but Microsoft are simply not marketing them well enough. Since these are all you can install on a tablet device I would have expected something with a bit more flair to try and entice people to parting with their money.


Searching through the Store is not a very informative experience either

There are also technological problems too; the Store app is incredibly buggy. I’ve encountered warnings saying that internet connection is lost constantly and apps failing to install for some bizarre reason. If this is the only way into getting any software onto your device the Store should be as rock-solid as possible. It also poses this question: if the Store app manages all your Modern app updates how does the Store itself get updated?

General OS Gripes

Finally there are some general niggles that bother me.


The Charms bar I cannot see any point in, even on a tablet. When you swipe in from the right-hand side you are now presented with a bar of “charms”, or extremely common operations that are now built into the OS, such as Search, Share and Settings. Search and Settings I get – nearly everything these days require these functions – but Share simply looks like a symptom of the times we live in; perhaps there will be clever uses of this charm but for now all I can see it being useful for is to share things to Facebook/Twitter. If I’m working in Microsoft Office do I really need to tweet to everyone that I’m working on a PowerPoint presentation? I can see some point to sharing though but why not just limit it to the applications that require it rather than provide a great big button directly in Windows itself?

Windows 8 is also clearly a transitionary OS as is evident by having both the “Modern” Windows and the “legacy” Windows but this divide can also be confusing as there are now inconsistencies between how to do things. For example:

  • Windows 8 has a fullscreen settings screen but this is not enough to control everything so sometimes you will have to dive back into the Control Panel (which has not been “modernised”). And interestingly some settings are duplicated for no particular reason – setting up a Homegroup can be done exactly the same in the Control Panel or the new setting screen, so why have both?
  • The Desktop can also view the charms bar yet these become even more useless since the Desktop was not built to use any of them. If that is the case why show it at all?
  • The Desktop shows the time, date and items like network connectivity and battery power in the taskbar. The Modern UI hides all of those useful indicators until you make the charms bar visible.


An example of UI inconsistency – I’m in the old Desktop yet now I’m also in the Modern UI too?

Ironically in this touch-enabled future keyboard shortcuts have become the only way I can actually get to anything quickly these days; shortcuts like Win+C are far easier to perform that hovering my mouse cursor into a “hot-corner”, dragging down slightly and clicking on the charm I need. Also, as an experiment, get a brand new user who’s never seen a Windows 8 machine before to try and figure out how to close a Modern app or even how to switch off the device – see how long it takes them before they give up. I had to look these up online before I could figure it out and even now closing a Modern app is not intuitive – Alt-F4 to the rescue!

Is it Really That Bad?

No, of course not. Like I’ve already said I do like Windows 8 but mainly from a desktop user perspective. And while I do have a few Modern apps that I like overall I’m just not impressed with them.

The problem I see is that Microsoft took a big gamble trying to get Windows to work in such a way that it is suitable for any device, be it a phone all the way up to a PC, but I’m not so sure this gamble is paying off. Each device type is meant to cater to a particular set of requirements; phones and tablets are not meant to be processing powerhouses and are meant to be used on-the-go so making lots of content-consuming apps makes sense for those devices. PCs and laptops are meant to be more powerful and allow more finer control so it makes more sense to develop more productive apps (like Office) for them.

It may be that, one day, we are all using tablets for our computing needs so we need this OS which is touch enabled and easy to use but I don’t think that day has come yet and Microsoft have made that leap too fast too soon, leaving all of it’s users having to catch them up. Ultimately I’m starting to think that Apple may have had the right idea; build an OS for mobile devices and PCs but not both.

Now I’m not one for criticism without at least trying to present some suggestions for improvement. After all, everyone has their own opinion on how things should work. I intend to write up how I personally think Windows could have been done whilst also moving it forward but I will leave that for another post, so stay tuned for that.

Wednesday, 20 February 2013

Settling into Fatherhood

I’ve been quiet of late on my blog. That is because a couple of weeks ago this happened…


I now have a daughter, Little L. Along with my 21-month old son, Big M, I’ve now reached my target family size!

Having a second child actually makes you think back and compare how things were with your firstborn. For a start, like everyone tells you, the second one is easier in that you don’t worry so much about things; all that training, stress and exhaustion you encountered during your firstborn’s arrival puts you in pretty good stead for handling a second baby. All sorts of things like changing nappies (which I still have to do for Big M), feeding them, burping them, bouncing up and down to sooth them, it all comes back to you. And the sleepless nights somehow seem more manageable at the moment; I now know that eventually I will get my sleep back so that is a good way of looking at things.

My paternity leave this time was also much more enjoyable. During my time off work looking after Big M I basically experienced this for two weeks:


Whereas with Little L it was like:

“Oh, she’s crying. Let’s cycle through the changing-feeding-soothing cycle to see if that settles her”

It left me feeling that I could actually bond with my family rather than worrying about all the little details.

The only challenge I would say I’ve found is having to deal with a hyperactive toddler and a newborn at the same time. In general Big M is very interested in his little sister – no jealousy appearing yet – but he also hasn’t got a clue how to be gentle with her. One minute he can gently kiss her on the head, the next he can give her a big smack. Trying to get him to understand the difference at such a young age is difficult but he is slowly getting there. And I’m sure when Little L is older she’ll get her own back.

Normal service will resume on this blog soon albeit a bit slower as I now have to write my posts during my lunchbreaks at work, so stay tuned.

Thursday, 31 January 2013

GitHub for Windows: Git for Beginners

Git is all the rage these days; you can’t move around the internet without bumping into all kinds of comments saying how Git is amazing, distributed SCM systems are the future, and so on. I myself come from the age of Visual SourceSafe (shudder) and TFS where all source-controlled content is locked down until changes need to be made. I have no major complaints about how TFS works – it may be a bit of a beast but it does the job well enough for me – but I can also see the benefits of a distributed SCM system where changes can be made offline and “pushed” to a central repository when ready, which is where Git shines.

GitHub has also helped its popularity by bringing a primarily Linux-based system to the masses, including the Windows crowd. Having said all this Git also has its drawbacks too:

  1. It is entirely command-line based – which is to be expected given its Linux heritage – which initially tends to put some Windows developers off. Now I’m not averse to using command-line tools but sometimes it is just easier to see something visual in front of you.
  2. I also hear that there can be some confusing aspects of Git, such as features that can be used in a variety of ways using various command-line switches. Memorising the commands you need on a daily basis can introduce a bit of a learning curve.

Even so I wanted to try my hand at using it, especially as I had a small project in mind that I wanted to keep track of. But as a complete newbie how do I start? I could follow these steps outlined by GitHub and fiddle around with all kinds of settings and SSH keys, or I could let GitHub help me by using their brilliant client front-end GitHub for Windows.

What is GitHub for Windows? As their website says it’s “the easiest way to use Git on Windows. Period.” It is a desktop application which provides some core features that you would typically use Git for but in GUI form (such as committing changes and branching/merging) but additionally installs all the Git tools you would need anyway; if the GUI can’t do something you can always drop back down to the command-line tools (and it will even help set up your shell to assist you). At the moment I’m just using it for local repositories but I also expect the integration with GitHub itself to be top-notch.

Let’s go over the main features I’ve currently been using.

Installation and Setup

I can’t think of many development tools which are this easy to setup. In the past I imagine that a lot of effort would have been made to download all the Git tools (possibly even having to build them from source), set up environment variables, use various other tools to create SSH keys and so on.

Not so with GitHub for Windows. It all comes bundled as a ClickOnce application; I simply downloaded it, installed it and it setup up everything I would need in the space of about 5 minutes. After that all I had to do was sign-in with my GitHub account and I was ready to roll.

Create a Local Repository


You can of course connect to various repositories that are on GitHub but for the moment I wanted to focus on doing some local development on my own project; I’m not ready to make it public just yet. Again this is simple and straightforward; all I did was create a new repository under the local section and filled in a name and description of it. GFW (as I’m going to now abbreviate it as) then set up those special “.git” folders and initial files and I was ready to commit changes.

Committing Changes


This is actually the bit I’m most impressed with. I can go to Visual Studio and make all the changes I want to, then come back to GFW and it will have seen what has been changed since the last commit, providing you with a mini-diff window for each change made. Even if you delete a file that used to be in the repository GFW will notice it and remove the file on the next commit. Committing changes suddenly becomes incredibly easy and doesn’t require much thinking about.

Branching and Merging


Branching and merging is something that Git is apparently very good at; I had a read though this online book which explained really well how branches work in Git. GFW can handle branches very easily, simply create as many new branches as you want and easily switch between them using the menu.

To merge branches together is also simple; GFW has a branch manager window which shows all the active branches in the repository. To merge simply drag the branches to merge to the bottom of the window and hit the “Merge” button. It really couldn’t be easier.



Ah, and now we hit something that GFW can’t do on it’s own. It is generally good practice to tag releases of projects so you can easily find them in your commit history, but GFW does not support tags out-of-the-box.

Not to worry though, because we can simply use the command-line tools to do that. GFW allows you to open a shell setup for your repository – in my case it opens Powershell using some extra Git extensions. Then I can do something like:

# Add a tag
git tag -a "NewTag" -m "This is a new tag!"

# View available tags
git tag

This is a great example of how, when the GUI does not support what you do, you can always go back to Git as it was meant to be used.

Start of a Beautiful Friendship

I haven’t been this impressed with a piece of software in quite a while. Not only does GFW ease a beginner like me into using Git on a day-to-day basis but it is actually one of the finest examples of a WPF application I’ve seen yet; it is fast, responsive and hasn’t failed me yet.

I look forward to actually pushing my project to GitHub when the time comes!