Friday, 16 March 2012

The Beauty of Console Applications

We live in an age where computers are getting faster, smaller and more powerful. We can now create beautiful user interfaces with millions of colours, with all sorts of graphics, images and swish animations. These advanced graphical user interfaces can now be found on smartphones, tablets, and all over the web. So why is it day after day I actually now prefer making this kind of application?

Getting Straight to the Code

In my job I work on an ASP.NET website, but I also do a lot of development on back-end services and applications/tools that work around the website. The website is viewed by thousands of users from all walks of life; the back-end systems are viewed by me and three other developers at most. Do I really need to create a graphical user interface for these tools?

The fact is I can create a service/tool with just a console window far faster than anything with a GUI. All I do is fire up Visual Studio, create a new Console Application project in the language of my choice and I have enough boilerplate code to start working on the actual functionality of the program instead of having to worry about what it looks like first. Working on a WebForms page, in contrast, can suck up days of my time just trying to get the logic and the interface to work together, let alone style it.

It also means I can quickly create lots of testing applications which test all the core business logic of the website without requiring a graphical front-end. I like this kind of work and I try and apply this philosophy a lot more now; having to manually click through several pages to get to the one you need and then entering enough form information to trigger your test scenario tends to get very tedious I've found.

I'm a Developer, not a Designer

If you're going to create a GUI, and a great one at that, a lot of thought needs to go into what it should look like and how it should function (the user experience). I suppose the throughput of actions could be decided by me, the developer, and I can try and add a splash of colour here and there to make it look a bit fancier than the traditional battleship grey.

But I have limits. If you want a really good looking interface, you'll need the help of a designer to do it. I know enough HTML and CSS to accomplish quite a few things like positioning and layout, but when it comes to picking colour schemes or images or adding detail to those elements I get stuck since those are design issues. If it was down to me, all backgrounds would probably be white and everything else some shade of blue (I'm not the most imaginative person when it comes to design).

I don't have this problem with a console application; the only thing it can output is text, so that's my only option.

The Learning Curve

There is also the issue of having to learn how a user interface framework works. Take the Windows Presentation Framework (WPF) for example; it is a whole different ballgame to Win32/WinForms programming that came before it. WPF has a ton of features which make it far more powerful than WinForms, but that comes at the expense of a very steep learning curve. Suddenly you have to know about XAML and additional features like dependency properties.

There was also the advent of the Model-View-ViewModel (MVVM) pattern that fitted nicely with WPF due to its advanced data binding features. I once had a go at learning both at once and really had a hard time getting my head around it. What exactly is a ViewModel? How do I bind Views to ViewModels? Where do you even start when trying to learn this pattern? And that is just the concepts you have to understand, you still have to figure out how to apply them. I've still yet to find out how to do something as simple as show a modal dialog without jumping through several unnecessary hurdles - surprisingly not a trivial thing if you're going to stick rigidly to the pattern. And I'm still not a designer, how do I make all this look as pretty as other WPF applications I've seen?

There are really only two options available to me in a console application. For output I use Console.WriteLine(); for input I use Console.ReadLine(). Consider this framework committed to memory.

Not For Everyone

There are of course a lot of cases where it simply doesn't make sense to make a command line tool. I could never imagine my mum or dad, as typical computer users who can just about manage email and web browsing, ever looking at a CLI and thinking "wow, I'd love to try that" for instance. And sometimes a wall of text as output is not the easiest thing to digest or view at-a-glance.

But there is a sense of "beauty" in the simplicity of this kind of application I think. It's not pretty to look at and not everyone wants it, but it does exactly what it needs to and nothing more. For a lot of projects I do, that suits me just fine.

No comments:

Post a Comment