Coding With Pen and Paper

Producing a rough sketch on a piece of paper may seem more like the realms of a designer desperately trying to get an idea out of their head into a physical form to share with others but I find it can also help me develop backend code.


When starting a new bit of work I normally have the rough idea in my head of how I’m going to modularise the code and what functionality each piece will need. However, if I plunge straight into coding I can at times duplicate functionality that maybe better condensed into one function of a class that other classes can extend.

By listing all the functionality I require first I can then begin to separate these concerns into classes and functions. This helps me to spot where functionality is needed in several places and any variations that maybe required, e.g. giving the option to return in differing formats.


My head can be a great place to start work and it all seems very clear, but putting it down on paper really helps me visualise how code can work together.

Is there a certain flow of data that must be followed? Lining up each step with a simple visual and showing how data can flow through a process and the possible outcomes at each step will highlight any areas that need special attention.


There are so many times when I’m speaking to clients or colleagues and I wish they could see the picture that was in my head. Things that seem very logical to me can sometimes not be vocalised as simply.

By sketching out the concept it can help others to understand what the plan is and how all the pieces will work together.


As I move forward with the work it can be easy to start focusing on the small details of each individual piece of functionality. By having a good visual reference for the overall work it helps me to keep considering the overall functionality and how it will all fit together.

In much the same way that testing can help you organise your thoughts on how your code should be structured, I find that using pen and paper is a great way to get my thoughts in order and keep the work on track.

Curse of the Redesign: Moving to the Live Environment

When we develop sites we start off locally and in a development environment. During the development process we continue this process as we evolve the design and functionality.

But there comes a point where the site we’re working moves to the stage where it will become the live site. At this point it’s preferable to move it to the live environment.


We try and match development and live environments as much as possible but it’s not always possible to get exact matches due to various constraints.

By working on a live environment as early as possible any differences in configuration such as file permissions can be worked out early on.

With PHP and Drupal moving to Composer based workflows there constraints on PHP versions for different modules. Even Drupal will be implementing a minimum PHP version. Discrepancies like this need to be spotted and resolved as early as possible to ensure the site functions as expected when launched.


As I talked about in my previous post on Handling Existing Content, we often import content and do some manipulation of it. Further to this both the client and team at Headscape will add additional content.

We don’t want to risk this being incorrectly updated or lost. Having a copy of the site on the live server gives a clear distinction as to where the true source of content lies.

File uploads is another source of content that should not be ignored. By working on the live environment you ensure that file uploads and access work correctly, as described above with regards to permissions.

It also saves a time consuming task of moving any uploads from a development environment to the live environment before launch.

SSL Certificates

It’s rare to work on a site that does not include an SSL certificate. Even simple sites often have a contact form so data can be securely sent and combined with search engines ranking https sites better it makes a lot of sense.

I won’t go into detail here but in a previous post I detailed how to test an SSL certificate without the domain name.


Overall working on the actual live environment provides a nice level of reassurance before you make that all important DNS switch.

A simple thing like ensuring the server is correctly sending out emails can make launch day an enjoyable experience rather than a mad scramble to debug why your killer feature isn’t working as expected.

Curse of the Redesign: Handling Existing Content

As I spoke about in the previous post about redesigns my work generally focuses on clients who have existing sites that need to be moved to a new Content Management System and have a new design applied to them.

Whilst this can have it’s advantages for design work by allowing the front end developers far more freedom with markup it has some challenges for the backend.


Every database I have received have been from a different CMS, some have been MySQL and some have been Microsoft SQL database but all have required some discovery.

We do a lot of work in Drupal so I always import the old database to MySQL to make working between the two databases as smooth as possible.

Once I have the old database imported I then set about piecing together the structure. Most database are actually fairly simple when you start to look into them and follow the same patterns.

A base table with master ID
Associated tables with extra data tied to the masterID
A table joining master IDs together e.g. blog posts and authors

Once you have found the patterns it is usually the same for all content types that you will be importing.

Tidy Up

Running an import of data gives us a great chance to tidy up both content and data.

Tidying up the content can be simple clauses such as only import items that have been created in the last 5 years.

Or it can be more complicated. We worked on a project where the tagging had got out of hand so we set a limit of a maximum of 5 tags in the new site. This meant a decision had to be made on how to handle the import of a subset of tags.

We made a list of priority tags, if these were linked to from the item then they were included. If they were not then we had a manual review process. The manual job actually ended up being a lot smaller than anticipated and could be worked through very quickly.

Old data from a CMS is often littered with poor HTML that needs to be cleaned and during a pragmatic import of data is a perfect time to do it. A tool such as HTML Purifier can help you clean up that old mess.

Store IDs

Probably my top tip for importing data is to keep a mapping between the old IDs and the new IDs. This allows repeated updating of the data and also a useful way to compare the two data sets.

It also allows the import of join tables as mentioned above. If you import authors and store their old IDs when you import the blog posts you have a way of joining the two together. The basic logic would be

Find old author ID for this blog post
Look up mapping between old author id and new author ID
Set the blog post to be connected to the new author ID

Choose Candidates

If the dataset is large enough to warrant migration scripts then it is also too large to check every single imported item. Work with the client in selecting some candidate items for data comparison. This will mean you have useful reference points for both you and the client to cross check the imported data.

Use Your CMS Tools

Most Content Management Systems offer an API for data creation and Drupal is no exception. You should always use these APIs for content creation rather than inserting the data straight into the database.

Run It and Run It Again

The great thing about computers is you can get them to do things over and over again very quickly in exactly the same way.

We always have to run scripts many times. This can be due to new fields being added or data needing to be formatted in a different way.

It is also highly likely that lots of new content will be added between the time you got a copy of the old site database and the new site going live. All these items can also be imported saving the client manually adding them.

Get Stuck In

The first time I was faced with an unknown database it was quite overwhelming but many years on and many different databases in I’m no longer phased by it. My advice is to logically work through the data and always think about repeatedly running the import scripts.

Curse of the Redesign: Existing Content vs New Ideas

I can’t remember the last time I was involved in making a brand new website rather than an update or redesign. Maybe it’s just the sort of work we are suited to at Headscape and you may find differently.

A redesign often brings with it different challenges to making a site from scratch, one of these is challenging the client to provide new types of content. By sharing a vision of how their site could be it encourages clients to improve their site rather than continue with the same old processes.

Linked Content

One of the best ways to help users find relevant content on your site is to link to other pages that contain similar content or related subjects. You’ll probably know this best from “tags” which often appear on blogs like this one.

Over the years I have encountered both ends of the spectrum for related content.

No Relationships

It maybe that the current CMS does not allow it or it maybe that it was never thought of, but I have come across sites where there is no data linking any of the content.

Clients always see the benefit of doing this going forward but it is often hard to convince them to invest time in going over old pages and adding tags or links to other content. This doesn’t have to be an arduous task that is done in a single sitting, encourage people to tackle a small section at a time and share the work load around.

Too Many Relationships

Over time lists of tags can become over populated and some tags have been added twice with minor spelling differences. A complete audit of tags or other ways of linking content should be carried out to streamline the process and make it easier for both content editors and site users to navigate between related items.

Limiting the number of tags editors are allowed to choose is also a good way to focus them on the important ones rather than lots being selected as they don’t want to miss anything out.

Likewise on the front end do not output a huge long list of related content. Optimally 10 at maximum and then offer a way to “see all related content” through a pre filtered listing page.

Social Media

Now social media has been around long enough that the majority of people are using it and using it to consume content and communicate with other people and companies it is an area that should not be missed.

There are many good tools for automating Tweets for example, such as Buffer, and the major CMS provider, and I’m sure smaller ones, offer ways to automatically post new and updated content to various social media channels.

If the client is not used to using social media as a marketing channel it may seem like a lot of effort and another area of work. But introducing them to some automated tools will hopefully show them it needn’t be as much extra work as anticipated.


I would say the one type of content that clients find the most challenging to add to a website is imagery. This is probably due to good quality images being hard to find and also tricky to convey exactly what a page is about in a single image.

Most people can at least write some words to populate a page but taking good quality images is a lot harder. There are the stock photography sites but these are often cliched and over used. At the design we often help the client source images to get them started.

It may not always be possible to find an appropriate image or the page may not need one. The two options here are to either ensure the design works without an image. We often have banner images as an optional field. The other is to ensure that any placeholder images fit in well with the overall design, at all screen resolutions, and will will not be too distracting if used multiple times.

Trying It Out

By adding new elements to a design it can really liven things up and improve the overall look and feel of a site. My only word of caution is to make sure that the client can keep producing content with the new elements. For example if your design falls over when there are too many placeholder images and the client can’t produce new imagery you may have to reconsider that aspect.

Why Your Back End Developers Should Be In The Design Kick Off

Design kickoffs are great, it’s the start of the project, expectations are high, ideas are thrown around liberally and everyone is excited about what’s to come. So why should you bring along the person responsible fo database tables and code no one will ever see?

Get to know the business

Invitations to tender and design briefs are very useful documents to get an initial idea of what a business does and what they offer. You may even be able to gather some useful information from their existing website, or you may not and that maybe the reason you’ve been brought in.

Having attended many kickoff meetings now it has become obvious to me that you only really get to know the goals of a business when you speak to those that work there.

As an example the company streamline may be “We provide widget X to 90% of the industry” but when you speak to the web team the real problem is embedding YouTube videos means copy and pasting embed code into a text box. You aren’t hired to try and sell more widgets, you are there to help the web team be able to sell more widgets.

Overall knowledge of project

“We want to modernise the look and feel of our current site and make it responsive” this may be the driving force behind project but more than likely there are many other goals that the client has in mind that can easily be accomplished within scope and budget.

I can guarantee that in the meeting someone will jokingly complain about a current process that they have to go through that can easily be automated in the new project. When offering a solution to the client it is always met with a smile and a comment such as “that would save me so much time”.

Having a broader idea of the whole project can also help you set up for potential future work. Somethings may be identified that can’t fit in the current timescale but you can build in the foundations that will allow future updates to be made.

Possible technical hurdles

Whilst I love the excitement a new project brings it can be the case that enthusiasm takes over a little and it can be an excellent time to spot any potential technical hurdles that are flagged up. I have been on plenty of projects where it’s casually mentioned that content lives in this system or the data needs to be sent to another place for a contact database.

Some companies may have certain limitations on the technologies they wish to use. They may only want to use their own servers or a certain application stack to allow for easy integration with other services they use.

Forming a relationship

As I work for Headscape, who are an agency, rather than an in house team forming a relationship with clients early on is highly valuable for a good working relationship.

Once the kickoff is done I rarely see the client again face to face. We do however normally have at least a weekly meeting on Skype or GoTo Meeting. Having met in person I always find it helps these calls as you can at least picture the people and their mannerisms. In every project I’ve done the calls always have a friendlier tone to them after having met.

Gets me out for the day

Us backend developers may be stereotyped as shy people who want to sit in a room with no social interaction but if you are in two minds as to wether you should take your backend developer along to the design kickoff meeting I hope the above will convince you that it will really help the project if you do.

My first day with an Arduino MKR GSM 1400

I have a project in mind that needs internet connectivity but I won’t have access to WiFi so when I saw the Arduino MKR GSM 1400 with it’s GSM capability I thought I could use it to send my data over 3G.

Before I get to trying anything like that this is my experience using it for the first time.

Where do I put the SIM Card

I already had a SIM Card from GiffGaff to use I just needed somewhere to put it.

Spoiler alert: it’s on the bottom.

The bottom of the Arduino MKR 1400 with the SIM card slot on the right
The bottom of the Arduino MKR 1400 with the SIM card slot on the right

I was looking at the board still stuck in the soft foam and couldn’t for the life of me find the SIM card slot until I turned it over.

First Sketch

As you’d expect there is all the information you need to know about getting started on the Arduino website.

I followed the instructions and had the classic blink sketch up and running in seconds.

Second Sketch

I found a simple sketch that uses the GSM library to send a message. But that gave me the following warning

WARNING: library {0} claims to run on {1} architecture(s) and may be incompatible with your current board which runs on {2} architecture(s).

This was caused by including GSM.h rather than MKRGSM.h

From there I went to the MKRGSM Library page which has some useful examples including one to send an SMS message.

The sketch uploaded sucesfully but it got stuck on connecting.

I swapped the new SIM card for the one I use in my phone and that one worked. So I tried the new SIM card in a phone and it worked fine. I put the new SIM back into the Arduino and tried the sketch again, and still no joy using the new SIM card.

The top SIM does not work in the MKR 1400 but the bottom one does
The top SIM does not work in the MKR 1400 but the bottom one does

Going Forward

Overall the board was quick and easy to get going with. The hardest part is going to be figuring out why the SIM card isn’t working in it. Hopefully I can sort that and then get on with utilising the board in some projects.


Customer Service as a Service

In my younger days I worked in a surf shop where the owner was very hot on customer service. He liked us to greet every customer when they entered and left. To start with this seemed quite unnatural and the odd customer even seemed confused. In general though it did open up communication and people seemed genuinely happy with the interaction even when you said thanks to them for leaving empty handed.

Now I’m a web developer and spend the majority of my days sat in a room by myself but customer service is just as important. With you’re building an agency building a site or working on an app you will have customers and they deserve to be treated well.

These days there are many developers and agencies out there that all do fantastic work. You can no longer rely on being a scarce resource. Providing great customer service goes a long way to making the project enjoyable and successful as well as paving the way for repeat business and recommendations.

Be polite

It may seem like basics you teach small children but remembering to be polite in the digital world so not be taken for granted. A simple “thank you” when the client helps by sending you the updated text or images you requested sets up a good working relationship.

It’s their site, they use it, try to accommodate them

You may not always agree with your clients requests and often this comes down to opinion. At he end of the day they are the ones who are paying for a website and will have to live with it everyday.

As an example there maybe a content management task with two options.

  1. Simple technologically but harder for the CMS user
  2. Harder technologically but makes the CMS user’s job easier

Always try to go for option 2. I often find it’s the small things that make people’s lives easier that are most appreciated.

They may not understand as well as you, try different explanations

If only clients could see what I see in my head. Everyone learns and understands differently and concepts that make perfect sense to me about a database can be baffling for others. There are many times you will need to take a different approach to explanations to help clients understand your concept.

For me nothing is better than quickly mocking something up so we are all looking at the same thing rather than relying on a fuzzy dewscription that can easily be interpreted wrongly.

Check they understand, ask if they are happy

Sometimes people end up agreeing when they aren’t 100% sure of the outcome. There is always lots to be thinking about in web projects. Taking a few seconds at the end of a discussion to ensure everyone understands the next steps and they are happy with them can save doing unnecessary work when the client reveals this wasn’t what they really wanted.

Give options

I find there is rarely a single option for solutions. Many times it’s a case of there being at least two ways we could achieve a task, both of which come with pros and cons.

Using the above advice provide the client with the options and a clear explanation of the pros and cons and let them decide their preferred implementation.

It not just for customers

Looking back at my time in the surf shop it didn’t take long before I was chatting to everyone I came into contact with and I instantly recognised how this simple act made all interactions easier and more enjoyable. All of the above points can be applied to your colleagues as well.

For example if a designer comes to you with an idea for an interactive menu there maybe two ways it could be implemented on the website. Discuss the merits of each idea and which will benefit the design the best and everyone will be happy. The designer gets to choose the best visual and you don’t get a technically impossible PSD.

Back End Developers – Goalkeepers of the Web

When I was younger I wanted to join a football team. I had visions of scoring the winning goal and being the hero. Unfortunately I turned up with a pair of goalkeeper gloves, one of the others on the team decided I must be a goalkeeper then. And that’s the position I played for many years, and I loved it.

Now I’ve been a backend developer for many many yeas and I love that as well. For me there are some obvious parallels between the two roles.

Even a small mistake is a big mistake

I clearly remember charging out of goal to meet the incoming ball and blast back down the pitch to start an attack. Instead it bounced higher than I anticipated and went over my head. For any other player on the pitch and this wouldn’t have mattered but for me it meant we conceded a goal and were now losing.

As a backend developer a tiny mistake such as a missing semi colon can bring a whole site down. Compare that to front end where missing out whole closing tags can often be rectified by the browser. Those front end developers don’t know how easy they have it, is that why we make them learn a million different JavaScript frameworks and throw in inconsistent box models in browsers.

Leading from the back

One of my favourite parts of football was corners. I’m very average height but I can jump a lot higher than most people. I used to love to come running out, jumping through the air with a loud shout and claiming the ball. It let everyone in the team know I was there and taking care of my job.

Providing a solid back end for others in your team is critical to building successful websites and applications. From mapping out database architecture to providing valuable end points, your work is what feeds the output and allows for the rich content we have come to expect today.

I always evangelise the value of having a good base to build on. If we can have the data in a good format to begin with then pulling it out again in desired formats and combinations becomes a lot simpler. The phrase “S**t in, s**t out” is very appropriate here.

Embrace your personality type

Every year when we ordered a new team kit I was handed the brochure to make my choice. I flicked through and stopped on the one that was the brightest and loudest. I’ve heard many others, including professionals, talk about goalkeepers having a certain personality type and I could definitely relate.

I think back end developers also have a clear personality type. We are very analytical and love a problem. There are plenty of times I see my colleagues design work and think “I wish I had the design eye they have”, but I don’t, and I encourage you to embrace your place in web development that is such a wonderful ecosystem of so many different types of people.

A closing note

After the ball bouncing over my head incident I cried on the way home. In my first developer role I deleted a colleagues database they’d spent all morning crafting. I didn’t cry but did feel very very bad and spent the rest of the day helping them restore it. Individual mistakes happen but with a good team around you those mistakes will become tiny blips.

Make working from home work for you and your team

When I started working for Headscape I also started working from home. Our office is a 3 hour drive form where I live so commuting isn’t an option and as a family we were not looking to relocate.

In the past few years I’ve learnt a lot from home working and how to make it work for me and our team. Here are some tips that I have found smooth the process.

Be Sociable

We’ve used various chat tools to communicate over the years and I always ensure that I’m signed in and active.

A simple “Good morning” to everyone lets your team know you are at work and instantly opens up the opportunity for any dialogue. I like to think of it in the same way you would see someone is at their desk in a shared office.

On the flip side of this if you need to be left alone to really dig into something just let everyone know and either turn off communication tools or set yourself to away.

Be Consistent

It helps that I have a young family so keeping consistent work hours is good for family life. I find it’s also good for work life balance. I have clear start and end times and this stops work bleeding over into my outside work time.

I’m sure it would be very easy to start a bit late, have a longer lunch, then keep working into the evening. This could easily feel like you had actually worked all day long.

Be Available

Similar to being sociable I, nearly, always like to have some form of communication open. A quick response in Slack or a 5 minute chat on Skype can really help out another member of the team.

This is the sort of thing that can help a team be at it’s most productive and reduce any negative impacts of not being in the same physical space.

Be Grateful

Working from home is a great benefit for me and I feel very lucky that I have a job that can so easily allow me this privilege. It’s very easy to get caught up in the day to day of work, but every so often I remember how nice it is that I have that extra time each day saved by not commuting and the fact I’m there to see my children as they head off to school and when they return home.

Be Whatever

These are my experiences from the past few years and I appreciate everyone has different ways of working. Overall I would encourage individuals or companies to try home working and make it work for you.

Find total rows by day created with PHP and MySQL

I was recently asked by a client to produce a report of content posted by day. My first instinct was to query the database for all rows of the particular content type and handle the counting in PHP.

First Idea

  1. Query the database for all rows of content type X
  2. Create an array in PHP of days
  3. Loop through all rows
  4. Use PHP to figure out the day the row was created
  5. Increment the array element for that day

This seemed pretty inefficient though and felt like something some SQL could handle far better.

SQL Implementation

MySQL offers the WEEKDAY function that returns an integer showing the day of the week for the date it is passed. With “0” being Monday, “1” being Tuesday etc.

The next slight problem I had is my dates were stored as timestamps and weekday requires a date in the YYYY-MM-DD format, you can also optionally pass in hours, minutes and seconds.

MySQL functions to the rescue again. This time we need FROM_UNIXTIME function. This function takes a Unix timestamp and returns it in the correct date format for WEEKDAY.

I then did a loop from 0 to 6 and stored the results in an array for output.

The loop with query in ended up as follows. I am also using the MySQL COUNT function to just return the number of results as that is all I am interested in here.

$contentCount = [];

for ($dayCounter = 0; $dayCounter <= 6; $dayCounter++) {

$contentCountSql = "
 SELECT COUNT( AS contentCount
 FROM content c
 WHERE c.type = 'x'
 AND weekday(FROM_UNIXTIME(created)) = :dayCounter;";

$query = $PDO->prepare($contentCountSql);

$query->bindParam(':dayCounter', $dayCounter, PDO::PARAM_INT);


$result = $query->fetchObject();

$contentCount[$dayCounter] = $result->contentCount;


$PDO is a PDO connection to the database.

We loop through and get the number of rows, using COUNT, for each day and content type X.

This stored in an array with the key equal to the MySQL day and the value being the count.

So Monday would look like

0 => 763

Tuesday would look like

1 => 542