1.4 String Theory
Unveiling Some Of The Magic Of How Words Reach Your Computer Screen

The User Experience of a software application is held together with strings.
In the world of software development, the word 'string' has a very special meaning. To programmers, a string is a sequence of letters within quotes. Here are some strings:
"Password strength:"
"Low"
"Medium"
'lowStrength'
'mediumStrength'
"The password does not include enough variation to be secure. Try:"
You can probably make some sense of a couple of these. That last one, for example, is clearly some sort of message that you could expect to see on your screen if you created a weak password. Passwords, by the way, are also strings.
Because strings are expressions on human language, they carry the richest aspects of the communication between the designers/builders of an application and the people who use the application. If you've read my previous articles, you can probably see how strings play a critical role in defining the User Narrative that helps users understand what to do and how to do it.
I consider the User Narrative to be an essential part of designing the user experience, I want to describe how strings are used inside a computer program.
But first let's continue that analogy, from the previous article, of web applications appearing on the 'stage' of your browser. But this time, let's reverse the analogy. Let's look at a bit of a Shakespeare script as if it were a computer program.
| HAMLET | [Advancing] What is he whose grief |
| Bears such an emphasis? whose phrase of sorrow Conjures the wandering stars, and makes them stand Like wonder-wounded hearers? This is I, Hamlet the Dane. Leaps into the grave |
|
| LAERTES | The devil take thy soul! |
| Grappling with him | |
| HAMLET | Thou pray'st not well. |
| I prithee, take thy fingers from my throat; For, though I am not splenitive and rash, Yet have I something in me dangerous, Which let thy wiseness fear: hold off thy hand. |
|
| KING CLAUDIUS | Pluck them asunder. |
| QUEEN GERTRUDE | Hamlet, Hamlet! |
| All | Gentlemen,-- |
| HORATIO | Good my lord, be quiet. |
| The Attendants part them, and they come out of the grave |
Look at this script segment from Shakespeare’s Hamlet. In the first section, spoken by Hamlet himself, we can see various important ‘strings’:
“HAMLET”
“[Advancing]”
“What is he whose grief … I, Hamlet the Dane.”
“Leaps into the grave”
Shakespeare hasn’t just provided us with artful speech uttered by his characters, he has also ‘programmed’ critical keywords and phrases that the audience will never hear but will have a fundamental effect on their experience of the play.
The first one is so obvious we could easily miss it. The word “HAMLET” tells the players that the Hamlet character does the talking for this section. The other ‘hidden’ phrases are marked in yellow. These are clear instructions from the playwright to the director of the play to tell her what should be happening on stage at that time.
So the string “HAMLET” on the left identifies the unhighlighted words on the right as speech uttered by the character named Hamlet. Character identifiers such as this are special strings because they define much of the structure of the play itself. If these character identifiers were not present in the script, it would be difficult for the performers to know who says what and the audience would no doubt witness a diminished ‘user experience’.
A computer program is a similar mix of hidden ‘internal’ instructions and non-hidden ‘external’ words that are presented on the screen. In a computer program there are many hidden strings that bind the logic of the program in fixed, predictable ways. Here are some examples of 'internal' and 'external' strings:
'password' => array(
...
'sameAsUsername' => t('It is recommended to choose a password different from the username.'),
'confirmSuccess' => t('Yes'),
'confirmFailure' => t('No'),
...
);
The bolded words on the right side of the arrow are all words that would be displayed on the computer screen. They have a special name: presentation strings. They are a critical part of the user experience because they tell the user what to do.
The words on the left side are quite different. They tell the computer what to do.
The strings "sameAsUsername", "confirmSuccess", "confirmFailure" are like labels on digital drawers which are places to store the various presentation strings. In this case the drawers are all grouped together, like a chest-of-drawers, that itself has a label 'password'. So the sentence "It is recommended to choose a password different from the username." is stored inside the drawer labelled "sameAsUsername".
The spelling of the label "sameAsUsername" is extremely important to the functioning of the program. If you change a single letter of this special code string, the presentation string won’t be found again and the program will break.
On the other hand the contents of these drawers, the presentation strings, need to be much more flexible because they have to carry not just the right spoken language, but also the right idioms for a given user group. They carry the art of the application's primary communication, just as the speech of Shakespeare's characters carry the art of the playwright's genius.
A well architected development platform will make sure that presentation strings are easily modifiable for this reason. In the example above, you’ll note that the presentation strings are placed inside some funny code that looks like this: t(). This is called the ‘t’ function and is a key element of the Drupal development platform. It gives the application designer a certain degree of control over the words that reach the screen.
Non-presentation strings, such as "sameAsUsername", "confirmSuccess", are inflexible fixtures that represent important parts of the structure of the program. As I mentioned, these fixed strings are like labels on drawers identifying where particular presentation strings are kept. When it’s time to present these strings, the program will look in these drawers, based on their labels, and will carry the contents off to the screen for you to see.
Fixed strings function very well as labels for digital storage like this. But fixed strings are also used to determine the logic of how things get done. Here’s another example:
if ($operation == 'add_role' || $operation == 'remove_role') {
// (do something special here)
instruction1();
instruction2();
...
}
The thing called $operation is not a string but it is another piece of digital storage. In this case, $operation, is not like a set of drawers, it is more like an individual fortune cookie. Inside that fortune cookie there might be one of several phrases, or strings. You won't know exactly what's in there until you open it. Here, we see two of the possibilities:
- "add_role"
- "remove_role"
So the program works like this: when the computer reaches this instruction it checks the string inside the $operation fortune cookie. If the fortune says either "add_role" or "remove_role" another set of instructions, between the curly {} brackets, will be executed. Isn’t that cool?
So these 'internal' strings can be labels on drawers or messages inside fortune cookies, or even other more elaborate mechanisms. They are all used to define a solid, reliable structure for the program. The most important thing is that these kinds of strings are inflexible and should never be altered.
Just as presentation strings have to be flexible to capture the art of communicating to targeted users, these ‘internal logic’ strings have to be absolutely rigid, or else the program will break.
So why call them strings? After all, strings are all about flexibility and a rigid string is not very useful.
Well, frankly, it’s very unfortunate that the programming community doesn’t have a better word, or even a different word, to describe these 'hard coded' letter sequences. So, for the purposes of this article, I’ve decided to call them ‘nails’. The image of a nail is much more appropriate word to describe a hard coded letter sequence, that is used to hold things together in a solidly defined structure.

Code nails and presentation strings are both sequences of letters within quotes. But they serve completely different purposes. Code nails are like the character identifiers and stage directions that give Shakespeare’s play a feasible structure. Take them away and you’ll have a babbling mess. Presentation strings are like the speech uttered by the characters. Take them away and you have no User Narrative.
Before closing, I should just mention that not all code nails are created equal. Just as you would use finishing nails rather than roofing nails on fine cabinetry, certain code nails need to be just as finely shaped. In the next article, I’m going to take you deeper into the programmer’s world to show you ways of building better nails. I'll also describe how to use these better nails to build a software development system that helps user experience designers get proper control of shaping the User Narrative.

