Knowing how to code can make a designer’s life easier

The debate about whether designers should be able to code or not is not new. This article (‘The “designers should code” bullshit and a not so new idea‘) addresses the debate from the ‘no’ perspective. Others, such as Elliot Jay Stocks (‘Web designers who can’t code‘) believe designers should know HTML and CSS, but not necessarily front-end languages like JavaScript, let alone back-end ones, such as Rails or Python.

Both sides put forward many arguments in support of their position. While I can see merit in arguments from both sides, it’s not my intention to re-hash those arguments here; you can read the articles for yourself. Instead, there’s one pro-coding argument I’ve never heard put forward that I believe deserves an airing: knowing how to code can make your life as a designer easier.

Many jobs a designer will face contain boring and repetitious tasks; it’s why Photoshop has actions – and why designers use them. But many of those repetitive tasks don’t have a helpful UI to take away the pain, or the UI lacks the flexibility or power to accomplish everything you require. So here are two examples of when knowing how to code can make your life easier. These examples require OS X and use AppleScript; I don’t know how much of these tasks you can accomplish on Windows, but I doubt it will be as easy as doing it with AppleScript.

Example 1: Automating Illustrator with AppleScript

One of my current projects requires me to create a lot of SVG images in Illustrator. The process of creating each image requires the placement of Photoshop files, for reference, and the creation of objects which act as guides, but that have no place in the exported SVG. Paths with strokes also need to transformed into outlined objects to ensure that the SVG code will work with the Raphaël JS library. Deleting objects and outlining paths manually is fine the first time. By the fifth image it’s a chore, and when you have to do it dozens of times it really grinds.

But there is an answer: you can use AppleScript in OS X to control Illustrator to accomplish this automatically. Here’s how:

You can’t create an Action in Illustrator to do all this, so without code you’d be left doing this manually; which is mind numbing, and as with any repetitive, automaton task, is prone to error when a human has to execute it manually. It also saves you time, giving you more time to be creative.

Example 2: Mass uploading files via FTP with Fetch and AppleScript

Another project I was involved with required regularly uploading files via FTP to up too 100 instances of a VLE. Often I found that I would be required to upload the same file(s) to every instance, a plugin for example; the structure of the VLE meant code centralisation wasn’t possible. FTPing a single file to a single site is easy, doing it to ten sites is boring, but acceptable. Doing it to 100 sites is pure tedium, and is not a very productive use of your time.

To alleviate the tedium we can use AppleScript to automate FTP-ing with Fetch like this:

This particular script is fairly simple, it is designed to FTP the same file/folder to either of two remote sites, each containing multiple instances of a VLE. It does this by looping through a list of folder names in a directory on your Mac, using the folder names to access the equivalent directory on the specified remote site. The key here is to mirror the remote directory structure and folder names locally. This script is a massive time saver, and removes the chance of making an error. Subsequently, I’ve written more complex versions of it that use the presence/absence of local sub-directories to determine whether to upload a file/folder.

Some people in the anti-coding camp, will say that this type of task is the responsibility of a developer, not a designer. However, not every designer is in the position to wash their hands of this kind of task; the project may not have enough developer resource or your developer colleagues might not have the time to do it, and so it falls upon you, the designer.

If you don’t know how to code, then you probably won’t be aware of AppleScript and what it can do; and even if you do you’ll likely lack the confidence to utilise it. I’d never used AppleScript before writing these scripts, but because I know how to code in other languages I had the confidence to dive into it.

Neither of these examples is complicated. AppleScript is often referred to as a ‘natural language programming language‘, which makes it easy to read and understand (even non-coders should be able to grasp what is happening here) it also makes it a good language to start learning with. Take a little time to learn the basics of coding – variables, strings, arrays, loops, conditional statements, functions – first. Understanding the basics will give you the fundamentals to make use of any coding language; everything else is syntax and vocabulary.

A final thought: when you’ve learnt how to code you’ll find that as well as making your life it easier, it can also open up new creative possibilities. This library of Illustrator scripts by Hiroyuki Sato shows you the creative possibilities of code. You don’t need to understand code to use them, just load them up in Illustrator; they’re JavaScript and so work on both OS X and Windows. However, if you open the JavaScript files in a text editor you can look at the code to understand how they work.