11 Jun

Student Munch

StudentMunch.com

Kershaw's Fish & Chips with Mushy Peas review

Kershaw’s Fish & Chips with Mushy Peas review

An independent food review site aimed at students; covering everything from tinned food to ready meals. Written in HTML5, CSS, object-oriented PHP and SQL. Plans to introduce a “Login with Facebook” feature in the future.

Semantic data

Student Munch is marked up semantically so that it can be interpreted as a review by search engines.

I use semantic markup so that my reviews can be indexed and displayed appropriately in search engine results. This site would work well as a WordPress site, but I don’t believe we should become reliant on third-party libraries and frameworks and should still learn how to do complex things manually. This has become an educational experience in which I have written code that allows me to upload review images (resized and condensed for high performance over slow networks), manage user accounts from the back end and automatically create search engine optimised URLs.

15 Jun

How stressed are you?

http://www.bbc.co.uk/news/health-24756311

Developed spoken-language-agnostic applications which can then be used by BBC World Service. Translated into eight languages. In the UK alone the stress test was viewed almost 1.9 million times and shared 106,000 times in the first seven days after publication.

15 Jun

NHS Winter

NHS Winter

http://www.bbc.co.uk/news/health-25055444

Premise

User can enter their postcode into a postcode search module, taking them to the BBC NHS Winter landing page and showing them the details of their nearest hospital. They can see whether or not their hospital is hitting governmental targets.

Critical reception

Nominated for several awards.

Technical details

The postcode search module uses an API to return the nearest local authority, which is cross-referenced with a predefined JSON data structure representing the hospitals in England. The nearest 3 hospitals are returned to the main application.

The app then renders numerous figures and charts to show the user whether or not their nearest hospital is hitting its targets.

Main app is fully responsive, triggered by URL parameters, makes good use of the observer pattern.

15 Jun

Zaatari refugee camp: Rebuilding lives in the desert

Zaatari refugee camp: Rebuilding lives in the desert

http://www.bbc.co.uk/news/world-middle-east-23801200

Image-zooming, interactive birds-eye-view of the Zaatari refugee camp, using the OpenSeadragon library. Users navigate through the panel controls on the right.

Also developed for BBC World Service, which required layout changes and considerations for right-to-left languages.

12 Jul

Tube Spotted

http://tubespotted.com

Premise

Inspired by the ‘spotted’ Facebook page craze that swept the internet in 2013, I realized that there was no central place for Transport for London users to vent their frustrations. Millions of people use the tube and overground services in London every single day, and as a newborn Londonder I know only too well the frustrations and oddities these services can bring.

Tube Spotted provides an anonymous platform for transport users to complain about the inconsiderate actions of other users, flirt with travellers who’ve caught their eye, and generally share their travel experiences.

Technical details

I carried over much of my BBC front-end web experience to this development. RequireJS AMD modules separate my JavaScript into logical modules. The experience is as seamless as possible, with a drag-to-update mechanism popular with Android/Apple devices and a continual scroll function that dynamically pulls in more messages via AJAX.

Message flagging is community-driven such that if a post is flagged enough times it is automatically hidden. Administrative intervention is also built in, so that I can manually approve or hide individual posts.

Image uploading is also an option, with PHP used to resize the image and store its path in a MySQL database.

TubeSpotted was designed using a mobile-first approach and is fully responsive. It also has additional metadata in the markup so that it displays well on devices, e.g. iPhone icon.

11 Jun

Aber Mads

AberMads.co.uk

The Elizabethan Madrigal Singers, Aberystwyth University’s longest running society, needed an improved web presence. I built the new official website from scratch using HTML, CSS and JavaScript, then added functionality using PHP and MySQL. We hope to attract some bookings, and therefore increased funding for the society, as a result of our new website.

11 Jun

Radioactive Evolution

http://chrisbashton.github.io/Radioactive-Evolution/Website/

I’ve hand-picked this university assignment because a) you’ll probably have a great deal of fun playing it, and b) it shows my first foray into Object-Oriented Javascript and the HTML5 Canvas. This game is open source and has been designed to be as independent and portable as possible (it can be downloaded and run locally- or uploaded to websites- with minimal fuss).

Gained 88.75% for this assignment (a high first).

01 May

The pessimistic ultimatum

When developers do their work, they should constantly bear in mind two scenarios.

What if my computer blows up?

What if I blow up?

These two questions encompass what I like to call ‘the pessimistic ultimatum’, which questions what might happen should the worst happen.

What if my computer blows up?

Let’s consider the first scenario. Though it’s unlikely your computer will ‘blow up’, there’s always the chance your hard drive will fail, or your laptop will get stolen, or you accidentally run some dangerous rm -rf * command.

You’ve been coding solidly for five hours, and have been saving locally every few minutes, when suddenly your laptop dies. What do you do now? Is there any way of getting your hard work back?

One should always bear in mind the possibility of hardware failure, and ensure they have at least a moderately up-to-date version of their work copied somewhere not on the local machine.

GitHub, or some other source control system, is probably the best solution. Don’t be afraid to push your changes on a fairly regular basis; at least a few times a day is good practice.

An automated backup system is a good alternative if you can’t be bothered with Git. Keep your project inside something like Dropbox, where all changes are backed up in the cloud and files can be pulled down remotely from any computer, provided you remember your Dropbox username and password.

At the very, very least, copy your work to another device, be it a portable hard drive, USB stick, or another computer. However, these backups are subject to the same risks as the local computer, and I even know of someone whose computer crashed halfway through copying to a USB drive, rendering both copies useless.

What if I blow up?

Though your own spontaneous combustion is even less likely than that of your computer, you can never guarantee your life won’t be cut short by an unexpected bus careering around the corner, or a knife-wielding murderer, or a slip onto the cold, unforgiving pavement.

It doesn’t necessarily need to be your own demise that gets in the way of work- you can be taken ill, or forget the password to your account, or simply forget to document your work before switching jobs.

Backing up your work to multiple locations is half of the problem. The other half is sharing your knowledge with others so that your work can actually be put to good use.

Let’s go back to that code you’ve been working on for five solid hours. Stop and think to yourself: ‘if I pop my clogs in the next couple of hours, will someone be able to find my work? Will they understand how to set it up, what it does, how to fix it if errors occur? Would it be simpler for them to rewrite from scratch everything I’ve written to date?’

Every minute of work that you do is utterly worthless if it isn’t backed up, or if nobody understands it. It is well worth investing at least a few minutes in writing a README.md that explains the purpose of your code and how it can be used.

Documentation isn’t the be-all and end-all, however, and nobody will be able to read your README if they don’t know where your project lives, or even that it exists at all.

I’m not saying that you should email your last will and testament at 5pm every day to everyone in your corporation. But do make sure that you make life as simple as possible for whoever lands the unfortunate job of overseeing your project if you’re not around. Do they know where everything is? How to set everything up? What to do, who to contact and where to go if something goes wrong (or right)?

If you disappear off the face of the earth today, will the organisation be able to cope tomorrow? Answering this may mean going as far as training another member of staff so that at least one other person knows [insert obscure programming language here]. Or making sure another developer knows a password to the system. Make sure you cover every eventuality.

We all want to be indispensable to our employers. The very best developers achieve this by being as dispensable as possible.

16 Apr

How to differentiate between links

When you visit a new website and are about to click on a hyperlink, do you know what is about to happen?

In the early days of the internet, a link was just a link. You’d click it and be taken to a new page.

Nowadays, clicking on a link can trigger any number of different behaviours. It may, as before, be an ordinary link that takes you to a new page. It may, however, open the link in a new tab or window. It may even trigger an event on the same page, such as an alert, or open up a floating box full of text (this is a common design pattern for displaying ‘Terms of Service’).

Personally, my sites open links in the same page by default, only opening in new windows if the link is to a different domain. You might disagree with me and think along the same lines as Vitaly Friedman – that you should never force links to open in new windows – but the point of this blog post is not to discuss the merits and disadvantages of each approach. Gotta leave me something to write about in the future!

No, this post is about tackling a design problem that has been worsening since the turn of the millennium.

The problem for website users

When you click this link, what do you expect to happen? You might be able to gather some clues by hovering over the link and hoping for some information to appear. But you can’t do that on touch-screen devices. And even if you could, the information can be missing, masked, or downright misleading.

This looks like a link to a review site: Food Review Site

In fact, it triggers an event on the current page.

We could make things more explicit by writing our links like this:

Google (opens in a new window)

But this is a long-winded, ugly way of indicating the link type. We need something more concise. Something immediately recognisable without the need to concentrate.

Ideally, we want to follow a consistent standard so that a user who has never even been on your site before will be able to accurately predict the browser behaviour when clicking on a link on your page.

The de facto standard

Increasingly, websites are adding a small icon next to links that open in new tabs. Here is a screenshot of Wikipedia’s implementation:

New window icon - Aberystwyth University page on Wikipedia

Though these icons vary slightly from site to site, the principle is the same – a small icon that indicates the link’s behaviour.

The problem for developers

So, we have a solution to the problem. What’s the issue?

The issue is that it is a pain to implement. Namely, it’s a pain to remember to do- and to actually implement- the manual addition of an image next to each of your applicable links. It may be quicker and more maintainable to add a class to your links, e.g. “.opens_in_new_window”, which you can style from within your CSS – but that doesn’t relieve the burden much.

If only there were a way for links to be targeted automatically…

The solution

a[target=_blank] {
    background: url('data:image/gif;base64,R0lGODlhCwALAJEAAP///5mZmf///wAAACH5BAUUAAIALAAAAAALAAsAAAIdlIOJJgEPA3MKKGdRfjRtu3UcFGFXRVpTqh6nZBQAOw==') no-repeat center right;
    padding-right: 15px;
}

This is a simple snippet of CSS that applies a ‘new window’ icon to all of your links that open in a new window. That’s it.

The url is a base-64 encoded image, which saves the browser from making an additional HTTP request for the image. If you don’t like the one I’ve used, you can encode your own icon at http://www.base64-image.de/ (and this is a nifty example of it working!)

Advanced attribute selectors (a[target=_blank]) work in IE7 and above, and base 64 encoded images work in IE8 and above, so there is substantial cross-browser support and backwards compatibility.

Let me try it!

Try copying the following into a file on your computer, save it as index.html, open up in your browser. You’ll see two links – the first opens on the same page, so has no icon, whereas the second opens in a new tab, so has the icon.

<html>
    <head>
        <title>New Window Icon</title>
        <style>
        a[target=_blank] {
            background: url('data:image/gif;base64,R0lGODlhCwALAJEAAP///5mZmf///wAAACH5BAUUAAIALAAAAAALAAsAAAIdlIOJJgEPA3MKKGdRfjRtu3UcFGFXRVpTqh6nZBQAOw==') no-repeat center right;
            padding-right: 15px;
        }
        </style>
    </head>
    <body>
        <h1>New Window Icon</h1>
        <p>
            <a href="#">Internal link</a>
        </p>
        <p>
            <a href="#" target="_blank">External link</a>
        </p>
    </body>
</html>

That’s an important design problem solved in just 4 lines of CSS – and one of those is a curly bracket!

04 Jul

Stupidly Simple Programming – Introduction

A lot of my friends and family have not got the faintest idea of what Software Engineering entails. Are you one of those people? If I tell you I’m a programmer, do you think that it has something to do with Google, or Microsoft Word, or hard drives or Windows or gigabytes?

If you can’t tell a program from a plunger, you’ve come to the right place. I’ve been meaning to write a foolproof, absolute back-to-basics guide for some time, and here it is.

Prerequisites

I’m going to assume two things:

  • Your computer is running Windows (e.g. Windows XP, Vista, 7, 8)
  • You have an internet browser (you’re probably reading this using one! Internet Explorer, Chrome, Firefox, Safari and Opera are popular browsers)

Choice of Programming Language

There are literally thousands of programming languages in existence, so where do we begin? I’ll let you in on a little secret- most languages are very similar or even identical in places, aside from a few syntactical differences. What I mean by this is that you can write a program in one language and change it into another language by simply changing a few words or lines of code!

To give you an analogy, think of a program as being like a car. There are many different makes of car, but they all use pedals, a steering wheel and a gearstick in much the same way- all you need to do is pass your test and you can drive any car. Learning your first language is hard, but on the flipside, once you’ve learned one language, many of the concepts and coding styles you learned in your first language can be easily transferred over to subsequent languages.

In this tutorial, we will be using the JavaScript programming language, which is the most widely used programming language on the web (as opposed to languages used in developing desktop software or mobile apps).

Choice of IDE

You may or may not have heard of IDEs, or Integrated Development Environments. These are essentially desktop applications (just like Internet Explorer, Windows Media Player or iTunes) whose sole purpose is to help you to write code. Think of it as Microsoft Word, but where you write code instead of books and other documents. They provide features such as syntax highlighting (colouring in some of your code to make it easier to spot mistakes), program compilation (some programming languages require compiling your code before it can run- you need not worry about that at this point), and debuggers (tools to help you to find and fix errors in your programs- again, don’t worry for now).

Eclipse is a popular IDE, as is NetBeans. These two are widely considered to be the industry standard and provide some great features, but are overkill for the purposes of this tutorial. We will be using Notepad++, a lightweight IDE that we’ll use mainly for syntax highlighting.

I should point out now that IDEs aren’t required for coding- not by any means. You could use any text editor you wish, e.g. Windows’ built-in Notepad. However, IDEs do make life easier in the long run and it’s well worth installing at least a lightweight IDE like Notepad++.

Getting Started

Download Notepad++:

Notepad++ Download

Run the installer:

Notepad++ Install 1

Keep clicking next. Simply leave everything at their default settings.

Notepad++ Install 2

Notepad++ Install 3

You’ll have it installed in no time.

Notepad++ Install 4

Now, when you run the program for the first time, you’ll probably see a textual list of what’s new in this particular version of Notepad++. We don’t care about all that- press the “Close” icon circled in the image below.

Notepad++ Installed 1

The list will be closed and a new document will be automatically started in its place.

Notepad++ Installed 2

We’re now ready to begin.

Let’s get coding!

Well… almost. We’ll be writing JavaScript, but before we can write a program, we need to write a HTML page. HTML, or Hypertext Markup Language, is the structural markup of the web. Every web page you access, including this one, is structured using HTML. HTML is NOT a programming language- it is a markup language. It has no logic.

Here’s a quick crash course in HTML. Copy the following HTML code into your document (make sure you don’t copy the line numbers!).

<html>
	<head>
		<title>Hello World!</title>
	</head>
	<body>
		<p>Hello, world...</p>
	</body>
</html>

Before we examine what we’ve just written, let’s make it a little more readable, shall we? Tell Notepad++ that we’re writing HTML.

Notepad++ Installed 4

That’s better. Believe me, it may not look that impressive right now, but when you get into programming you will cry if you ever have to work without syntax highlighting.

So what do we have here? We have what’s known as a html element. On line 8, we have a closing html element. Everything between these two HTML tags is said to be nested between them.

As a general rule, head contains everything that the browser needs to know but is not supposed to display, what’s known as the metadata. Later on you’ll be importing scripts and stylesheets within these head tags. Everything within body is the stuff that is actually going to be shown to people on your website. p informs the browser that the content within the p tags is a paragraph.

While we’re on the subject, what’s all this “Hello World” business about? I remember reading through my first few tutorials and being annoyed that everyone seems to use “Hello World” like an inside joke they wouldn’t let me in on. Well, here’s a simple explanation.

There are tutorials for everything on the net, including beginner tutorials for all sorts of programming languages. These beginner tutorials could just as easily be called “Hi Steve!” or “What’s the weather like?” or “Bla bla bla”. However, the computing community has collectively agreed that “Hello World” is as good a phrase as any, so beginner tutorials should use that phrase. This is a good thing. Why? Because it provides a common vocabulary. If you see a link to a “Hello World” tutorial, you’ll immediately know that it is a basic tutorial intended as a starting point for absolute beginners.

Right, let’s continue. Go ahead and save your new file!

Notepad++ Installed 6

Call it what you like, but make sure you save it as a .html file. Just make sure you can find it again.

Notepad++ Installed 7

Navigate to your saved file using Windows Explorer (see the above image). As it’s a HTML file, it’s very possible that if you double-click on the icon, it will open in your default browser (in my case, Firefox), but if it doesn’t, right-click on the icon and select “Open With >”, then choose your browser. It should open up, and you should see something like this:

Notepad++ Installed 8

Hey presto! You’ve made your first web page! Take note that your web page isn’t actually on the web– it is stored on your own PC, and nobody else can view it (you can’t copy and paste the URL in the address bar and expect people to see your web page by clicking on the link). Your HTML page is what we call stored locally. To put it on the web, you need a server or a web host, and that’s too complicated to go into right now.

But you’re not here to make web pages- you’re here to program. And now you’re ready.

The next chapter of this tutorial will be available soon!

Loading...