5
Jun
2013

Using PubSub in a Require.js app

by Stephen Fulljames

Recently a friend asked “Can you use Require.js with PubSub?”, and since I’ve just done exactly that on a project I thought it was worth writing up a simple example. The Publish-Subscribe (PubSub) pattern is a useful way to pass event triggers and data around an application without having to explicitly wire the origin and the target together. A PubSub mechanism, sometimes called an Event Bus, is used to publish data to named topics, and then any other part of the code can subscribe to those topics and receive any data that is published.

In this way, for example, an AJAX API can fetch data from a server and publish the results out to your Event Bus without needing to know where the data has to go – anything that is interested in it will pick it up.

The complication in this case is that the AMD module coding style that Require.js uses prefers splitting your code up into small chunks in individual files, and its maybe not clear how an PubSub mechanism would work across all these disparate parts. The good news is, its not too difficult!

I’ve created a simple example of a shopping list application which fetches the ingredients you need to buy from an API, and posts back to the API when you’ve picked up each thing. We’re making eggy bread, because that’s what my daughters asked for for breakfast yesterday.

The following code is written in Coffeescript, which suits Require’s modular style, but if you look at the sample app on Github there’s also a version compiled to plain Javascript if you prefer to read that way. There’s also a Grunt file in the project if you want to modify and build the code yourself.

The demo consists of an HTML file, which displays the shopping list and has appropriate buttons to trigger GET and POST behaviour on the API, and four Coffeescript files.

index.html
js/
  lib/
    knockout.js
    pubsub.js
    require.js
  api.coffee
  app.coffee
  config.coffee
  viewmodel.coffee

I’m using Knockout as a viewmodel in my HTML, simply because that’s what was in the original project code I’ve stripped this out of, but you should be able to use any MV* library you prefer or indeed any other method you like to present the data.

In the HTML we place a script element for the Require library, and set its data-main attribute to load the application config first.

<script data-main="js/config" src="js/lib/require.js"></script>

The Require config is extremely simple, we’re just creating paths to both the libraries (Knockout and PubSubJS) the application uses and then requiring the main application file and calling its init method.

require.config
  paths:
    "knockout": "lib/knockout"
    "PubSubJS": "lib/pubsub"

require ['app'], (App) ->
  App.init()

I’m not going to go into the minutae of how Require works, there are plenty of resources out there if you want to look at it in more detail and for now I’ll assume you have at least a basic understanding.

The application as well is not complicated, we’re requiring Knockout, and our Viewmodel and API classes, instantiating both of the latter and then using Knockout’s applyBindings method to wire the viewmodel to the DOM.

define ['knockout','viewmodel','api'], (ko,Viewmodel,API) ->
  init: ->

    api = new API();
    vm = new Viewmodel();

    ko.applyBindings vm;

You’ll notice at this point there’s no mention of the pubsub library, this is entirely contained within the Viewmodel and API.

Let’s take a look at the API. It exposes two methods – getContent and postContent. This is entirely faked for demo purposes, so all these methods do is wait 250ms and then return some data. The API class also stores an array of ingredients which is the data sample we’ll send to the Viewmodel.

define ['PubSubJS'], (pubsub) ->

  delay = (ms, func) -> setTimeout func, ms

  list = ['Eggs','Milk','Bread','Vanilla Essence']

  class API
    constructor: ->

      pubsub.subscribe '/load', (channel, msg) =>
        return unless msg

        @getContent()

      pubsub.subscribe '/remove', (channel, msg) =>
        return unless msg

        @postContent msg

    getContent: ->
      # equivalent of an AJAX GET
      delay 250, -> pubsub.publish '/loaded', list.slice 0

    postContent: (data) ->
      list.splice list.indexOf(data), 1
      # equivalent of an AJAX POST (or DELETE)
      delay 250, -> pubsub.publish '/removed', data

You’ll see that the class requires the PubSubJS library, and then in its constructor sets up a couple of subscribers for events that the Viewmodel will publish. The getContent and postContent methods then publish on their own topics when they complete. The postContent method also deletes the posted item from the array so if the user tries to get the list again we can pretend the API actually did something.

(The delay method is just a convenience wrapper for setTimeout to make it more Coffeescript-y)

And now the Viewmodel.

define ['knockout','PubSubJS'], (ko, pubsub) ->
  class Viewmodel
    constructor: ->

      @firstLoad = ko.observable false
      @status = ko.observable()

      @list = ko.observableArray()

      @instructions = ko.computed =>
        if @firstLoad() then 'All done!' else 'Time to go shopping'

      @load = ->
        pubsub.publish '/load', true

      @remove = (data) ->
        pubsub.publish '/remove', data

      pubsub.subscribe '/loaded', (channel, msg) =>
        return unless msg

        @list msg
        @firstLoad true unless @firstLoad()
        @status 'API content loaded'

      pubsub.subscribe '/removed', (channel, msg) =>
        return unless msg

        @list.splice @list.indexOf(msg), 1
        @status 'Item removed via API'

Again we require the PubSubJS library, as well as Knockout. Its constructor does the usual Knockout setup to create its observables and other viewmodel functions, and then binds the equivalent PubSub subscribers to listen for activity from the API. The @load and @remove methods are bound to buttons in the UI, and they publish the events which the API listens for to trigger its (fake) AJAX calls.

Both parts of the application are completely decoupled from each other, only communicating though PubSub, and this separation of concerns means you could replace the API or the UI without the other side ever, in theory, needing to be changed.

And that’s about all of it. To make the demo meaningful I’ve set the Viewmodel and HTML bindings up so that a shopping list is displayed after the user clicks the ‘Get list from API’ button, and removes items from the list when the API reports the remove behaviour was successfully posted.

So how does it work? The PubSubJS library, used in this example, operates as a global object so when the Viewmodel and API classes require it they’re referring to the same object. Therefore when topics are subscribed to, and published, PubSubJS’s event bus is available to all parts of the application and data can be received and sent from anywhere. That doesn’t mean you should neccessarily use that library. Backbone, for example, has PubSub built in through its event system. And others are available. But most work on the same principle so if you have a favourite, give it a quick test and make sure it works.

All the code for the demo is on Github so do check it out for yourself and play around with it.

31
May
2013

Thinking Digital

by Sari Griffiths

I have attended the Thinking Digital conference 2013 in Gateshead for the first time this year, having read a review comparing it to TED. And all in all, I think it lived up to my expectations. One participant I met even told me that he preferred it over SXSW!

There were around 30 speakers packed into two days. I’d say 80% were absolutely fantastic – that’s a pretty good hit rate.

Here are some ideas I found particularly interesting. I won’t go into too much detail but have provided links for you to explore. I heard that the videos will become available in about 6 months time. Or you can watch the past talks on their site.

Be collaborative, be creative, be agile

This may sound a bit self-congratulatory, but I found that we’re already implementing most of the ‘best working practices’ that the speakers were advocating. It was mainly about being collaborative, being creative and being agile.

The very first speaker Eddie Obeng kick-started the conference with an energy packed talk (wearing a very bright green shirt) that stressed the importance of working collaboratively.

Maria Giudice talked about being a DEO (Design Executive Officer). Aral Balkan talked about the need to put creative and user centred design thinking at the heart of business, showing many entertaining bad/evil user experience examples from the world around us – I was practically crying with laughter.

View from Thinking Digital
“Perfection is achieved not when there is nothing more to add, but there is nothing left to take away” Antoine De Saint-Exupery (introduced during Aral Balkan’s very entertaining talk).

Mike Bracken showed how his team changed the government’s perception of the web by using a more agile approach to their Gov.uk project. I was already impressed by their design principles and how they have actually managed to do it given that it IS a government project after all. Imagine the bureaucracy! During the talk, he shared a chart showing all government transactional services, and told us that they were understandably bringing the most popular services online first. The chart had a very, very long tail – the one at the end was ‘To obtain permission to scatter ashes at sea’ – so you know when that becomes available online, they’ve done it all!

There were many other speakers that touched on similar points. As I work in a company that works very collaboratively, creatively and in agile, it was great to hear that we’re on the right track. And we’re finding that it works for us.

Inspiring next generations

Many speakers talked about how they wanted to inspire their kids and the next generations of technologists. And it struck a chord (or code) with me, as a mother and an auntie.

TeenTech was introduced by the one and only Maggie Philbin, (what would be the modern equivalent of Tomorrow’s World?) bringing teenagers and experienced developers together to make something happen. Let’s get them excited!

Sugata Mitra‘s Minimally Invasive Education (MIE) was also very inspiring. It is basically about creating a self-organised learning environment without teachers present (but you need grannies and a teacher posing the right questions). A group of kids are given one computer (with internet connection) to share, and a question to answer together. Say if you want to teach them ‘cell differentiation’, the question will be ‘why can’t women grow beards?’. A teacher is still very important as you’ll need a right sort of questions. And a granny is important to give the kids some encouragement and positive feedback to keep them going. It is amazing to see how effective these approaches are.

There were two teachers, Jo Fothergill & Tara Taylor-Jorgensen from New Zealand, who talked about how they successfully used MIE to teach their pupils. Sugata himself is also setting up 7 schools (5 in India, 1 in Gateshead, 1 in Durham) to implement the approach. It will be interesting to see how they get on.

In a different talk, Julian Treasure was raising awareness of noise pollution. He said it was a serious problem, second only to air pollution, but no one was doing much about it. In a typical modern classroom, pupils that sit at the back of the room only catch 50% of what their teacher says because of bad acoustics. He also pointed out that playing music while you are studying definitely reduces efficiency as music are inherently created to be listened to, despite what teenagers claim!

Things are happening up North!

There were a few reminders that the North East has become the second largest tech industry after London. And that it’s being happening largely under the radar. There is a good reason that the conference was taking place in Gateshead! I will definitely keep an eye on developments up there.

And…?

Above are just a few ideas I found particularly interesting. There were loads more thoughts discussed that were nothing short of amazing.

If there was any thread going through entire conference, it was probably humility. Think about users. Think about people. Think about emotion. Considering the name of the conference was ‘Thinking Digital’, it was very interesting that it was as much about ‘Analogue’ as ‘Digital’, as one of the speakers said.

And I can’t wait for next year. I’ll definitely be there.

31
May
2013

Designers, learn how to code (at Steer)

by Michel Erler

First things first: my name is Michel, I recently moved to London from the maritime city of Bremen, Germany, and I joined Red Badger as a design intern a couple of weeks ago. I study Interaction & Moving Image at the London College of Communication and came here to get my teeth stuck into the wonderful world of technology.

As a young designer it feels kind of weird being so familiar with the internet and at the same time don’t know much about the way sites actually work. Every member of the web generation should know a bit about the (virtual) places they spend their time at. I knew I wanted to get a handle on coding, but needed a foundation to build on. Recently I came across a company called Steer claiming to teach anyone how to code and build websites. After a few  emails I decided to attend their intense front end web development course: Five days of key bashing leading to a kick-start in coding.

Rik explaining some JavaScript

Rik explaining some JavaScript

HTML & CSS 

So I arrived on Monday at their studio in Clerkenwell and was welcomed by a very friendly team with a tasty breakfast. Our course teacher Rik worked in web development for over 8 years and he was able to translate these hieroglyphics for us beginners into something that makes actually sense. We started with the very basics of HTML and that wasn’t as complicated as I thought. The very first site we built reminded me of the web how it used to be when I was six years old (e.g. Space Jam). We soon went on to more CSS and at the end of the day we had a simple, yet good looking site.

On the second day we learned about grids and forms, so we were able to build a decent site that could go straight on the net. Adding further CSS knowledge on day three I was quite surprised how easily you could create impressive 3D animations and cutting-edge layouts. 

JavaScript

On the last two days we went into JavaScript, mainly using jQuery. I think that’s quite a big step for a coding virgin. It’s challenging at first, but the result was pretty amazing. We went to another level of website designing, building responsive sites, integrating Twitter feeds and Google Maps or using parallax scrolling (every designer’s favourite right now).  

Conclusion

The course really demystified the world of coding for me. I never thought you can gain such a comprehensive set of skills within five days. Now it is up to me to keep up practicing and learning. Sites like codeacademy.com or teamtreehouse.com definitely make it a lot easier to keep you motivated. But in case you get stuck (which is highly likely to happen at some point) and you can’t figure out the bug yourself, it is good to know that Steer offers bi-weekly coding emergency sessions for all alumni. 

Coding really feels like an essential skill for the modern working world, especially if you have a couple of years ahead in your career. I am now in the position to create prototypes on my own. I probably even know some things a lot of front end developers out there don’t know as Steer teaches you the newest stuff available. All in all I was more than satisfied with the course and I’m thinking of attending the new iOS course in summer.  

There’s nothing to be afraid of. Don’t wait, learn how to code! 

To find out more about the different courses that Steer offers, just go to http://steer.me 

Photo: Steer

24
May
2013

The Makeshift Gradient

by Stephen Fulljames

Recently we helped our friends (and new “flatmates”) at Makeshift to build the first iteration of their website. They wanted something quick, lean and simple to get a presence out there without burning a load of time they could put to better use on their hacks. No problem – we put together a simple flat HTML page managed through Github Pages so that anyone on the team could easily push a change and have it deployed.

The more complex bit was the site header, an eye-catching grid made up of the swatch of brand colours Makeshift had chosen. You might think “nah that’s easy, its just an image”, but in order to keep the site scalable and responsive I decided to use a CSS gradient instead.

When you imagine a gradient you probably immediately think of a smooth graduation from one colour to another. So using a gradient to make a grid of blocks might sound as sensible as making jam out of bacon. But that works as well, so bear with me!

The key is that the CSS gradient specification uses “colour stops” to define where on the gradient the shade should change. Typically you would specify 0% and 100% as your stops to give a smooth gradient from one side of the element to the other. But if you bring those figures together – say 25% and 75% – you get a smaller gradient with flat colours either side. And if you put two colour stops in the same place? You get an immediate change from one to the other.

Gradient Examples 1

Extending from that, you can specify multiple colour stops and so create several bands of colour along an element’s background. You’ll need a colour stop at the start and end of each colour, so for Makeshift’s palette of 9 colours there will need to be 16 colour stops in your CSS rule. Why not 18? Because the initial stop at 0% and the final stop at 100% are implicit. Gradient Example 2

The rule for this is, as you might expect, rather long winded and there’s still quite a tangle of vendor prefixes to implement a cross browser CSS gradient. So we’re just going to give examples in the unprefixed linear-gradient syntax – however libraries such as Lea Verou’s -prefix-free can help you create the alternatives.

background: linear-gradient(to right, #e15c1b 11%, #9a937a 11%, #9a937a 22%, #cb6e40 22%, #cb6e40 33%, #8c9159 33%, #8c9159 44%, #484a35 44%, #484a35 55%, #522321 55%, #522321 66%, #a52e28 66%, #a52e28 77%, #a2726a 77%, #a2726a 88%, #dfa454 88%);

Live demo

This is great for a strip of colours, but to get the full Makeshift grid we need to go in both directions. You can’t do this with a single gradient, but you can put multiple background images on a single element and so overlap several gradients with the colour stops offset.

Gradient Example 3

Here we’re setting a background property with two linear-gradient rules, the second has the colour stops offset by five (so colour 1 in the first row is colour 6 in the second). We also need to set the background repeat to repeat-x, give each background a size and set its position.

background: linear-gradient(to right, #a52e28 11%, #a2726a 11%, #a2726a 22%, #dfa454 22%, #dfa454 33%, #e15c1b 33%, #e15c1b 44%, #9a937a 44%, #9a937a 55%, #cb6e40 55%, #cb6e40 66%, #8c9159 66%, #8c9159 77%, #484a35 77%, #484a35 88%, #522321 88%), linear-gradient(to right, #9a937a 11%, #cb6e40 11%, #cb6e40 22%, #8c9159 22%, #8c9159 33%, #484a35 33%, #484a35 44%, #522321 44%, #522321 55%, #a52e28 55%, #a52e28 66%, #a2726a 66%, #a2726a 77%, #dfa454 77%, #dfa454 88%, #e15c1b 88%);
background-repeat: repeat-x;
background-position: center 0, center 100%;
background-size: 100% 50%;

Live demo

For the final gradient, there are five rows to the grid and therefore five background image gradients. We also set the colour stops with pixels rather than percentages to be able to control the size that the grid appeared a little better, to allow it to repeat regardless of the width of the viewport, and to align accurately with the logotype.

Screen Shot 2013-05-24 at 14.36.03

This results in (unprefixed) CSS which looks like:

background-color: #df5a19;
background: linear-gradient(to right, #a52e28 86px, #a2726a 86px, #a2726a 172px, #dfa454 172px, #dfa454 258px, #e15c1b 258px, #e15c1b 344px, #9a937a 344px, #9a937a 430px, #cb6e40 430px, #cb6e40 516px, #8c9159 516px, #8c9159 602px, #484a35 602px, #484a35 688px, #522321 688px), linear-gradient(to right, #9a937a 86px, #cb6e40 86px, #cb6e40 172px, #8c9159 172px, #8c9159 258px, #484a35 258px, #484a35 344px, #522321 344px, #522321 430px, #a52e28 430px, #a52e28 516px, #a2726a 516px, #a2726a 602px, #dfa454 602px, #dfa454 688px, #e15c1b 688px), linear-gradient(to right, #522321 86px, #a52e28 86px, #a52e28 172px, #a2726a 172px, #a2726a 258px, #dfa454 258px, #dfa454 344px, #e15c1b 344px, #e15c1b 430px, #9a937a 430px, #9a937a 516px, #cb6e40 516px, #cb6e40 602px, #8c9159 602px, #8c9159 688px, #484a35 688px), linear-gradient(to right, #e15c1b 86px, #9a937a 86px, #9a937a 172px, #cb6e40 172px, #cb6e40 258px, #8c9159 258px, #8c9159 344px, #484a35 344px, #484a35 430px, #522321 430px, #522321 516px, #a52e28 516px, #a52e28 602px, #a2726a 602px, #a2726a 688px, #dfa454 688px), linear-gradient(to right, #484a35 86px, #522321 86px, #522321 172px, #a52e28 172px, #a52e28 258px, #a2726a 258px, #a2726a 344px, #dfa454 344px, #dfa454 430px, #e15c1b 430px, #e15c1b 516px, #9a937a 516px, #9a937a 602px, #cb6e40 602px, #cb6e40 688px, #8c9159 688px);
background-repeat: repeat-x;
background-position: center 0, center 86px, center 172px, center 258px, center 344px;
background-size: 774px 86px;

Live demo

Once all the browser-specific prefixes are included it’s a bit of a brain-melt to try and manage, but for the sake of our sanity we were at least generating it all through LESS with the colour values and grid size being variables in mixin rules. The most serious browser quirk we discovered was that Firefox (at the time we built the page) couldn’t handle the full 16 colour stops, so the -moz-linear-gradient and -moz-background-size rules needed to be adjusted to only show 7 colours out of the 9. The version at the time of writing (21) appears to behave better.

This does all depend on viewing the site in a browser which supports CSS gradients, multiple backgrounds and background size – but in mid-2013 that effectively only excludes IE9 and below, which Makeshift as forward-thinking hackers are willing to live with.

There were a few more complexities once the basic grid was up and running, such as how the cell size scales down through the media queries, and how the colour strip “sticks” to the navigation as the user scrolls down, but feel free to dig through the final CSS on the Makeshift site to see how it all came together.

20
May
2013

Something about the Quirky World of Mobile Web Apps

by Haro Lee

On a recent mobile-focused project we ran into a few challenges over getting what turned out to be a fairly complex layout working smoothly and responsively over a range of target devices. It also highlighted a number of real edge-case quirks in how different phones and browsers deal with modern web technologies such as the audio element, and even how ‘shake to undo’ can affect a form that the UI hid several transitions ago.

 

scr-300-a

(There was a time mobile phones were simpler… or not…)

 

Libraries

To help with the total payload of the project we chose to use the Zepto library rather than jQuery. This has an API very similar to jQuery’s and the advantage of size but is focussed on modern, mobile browsers so drops support for IE and – significantly – doesn’t cover Windows Phone. That wasn’t a problem on this particular project but worth bearing in mind for the future.

We found a couple of niggles in the Zepto API, mainly related to our own coding styles and the requirements of the project. We missed jQuery’s ability to set a hash of functions against AJAX http response codes, for example.

In the end, given the eventual size of the rest of the application’s payload, the filesize saving of Zepto over jQuery probably didn’t make a whole lot of difference.

 

How to be responsive

The biggest problem encountered while implementing a responsive layout with the given design was how the DOM flow needed to change depending on whether the screen is portrait or landscape. It would have been ideal if we’d had the option to change the design and eliminate the worst of the problems, but once we realised how complicated it would be it was already too late. So a lesson learned…

One of the big problems in trying to fit a fairly fixed size application design to a phone screen is orientation. Fine in a native app; you can just specify if the app fits to portrait or landscape, or both, but in a browser that level of control is not available.

Fitting the level of interaction we needed, responsively, into a landscape phone viewport meant quite a lot of juggling of DOM elements and events when switching from and to portrait layout. This was particularly tricky on iPhones as Safari in landscape orientation has three different possible sizes (address bar visible, address bar hidden, fullscreen) and generally smaller screen sizes than our target Android devices. The eventual experience in landscape wasn’t as satisfying as in portrait but we did manage to make it work.

Because of all the complexities that are not possible to handle only with CSS and media queries, we heavily depended on a Javascript layout manager to handle resize events and orientation changes, calculating available screen estate and rearranging elements.

A simpler way to get around this, although perhaps a cheeky one, would be to use the ‘orientationchange’ or window’s ‘resize’ event to effectively hide the main app with a “please turn your phone round” message. Unfortunately the ‘orientationchange’ event is not available on older Android devices.

 

Preloading

The procedure we used to preload assets for our single page web app was to have separate CSS files for the preloading/splash screen and for the main app.

The splash page was part of the app, so we didn’t want users to proceed from here and start using the main app until all the assets were loaded. To achieve this, we made one stylesheet for the splash screen with all the generic styles that didn’t require any images and another for the main app which referenced all images and assets (i.e. icons and background images) and only linked the splash stylesheet to the HTML page. We then used a Javascript preloader which requested all the image assets and the main stylesheet, attached this CSS file to the HTML page once everything was loaded and ready.

This method could also be used to load different stylesheets and assets depending on the screen size or device, if required.

 

Sounds

A new technology for us on this project was the Web Audio API which is a programmatic way of cuing and playing sound files rather than relying on a DOM element such as <audio>. Support is limited for now with only modern desktop browsers, and Safari in iOS 6, able to use it, but it looks to be a great way of adding spot effects to browser games and other interactions.

We used the Howler library to add sound to the application, with the expectation that we would use its fallback methods to increase support across devices and browsers. In the end due to other technical constraints (see ‘Device Quirks’ at the end of this post) we chose to only play sound through the Web Audio API, so if we were to refactor here we could have removed Howler (not that there’s anything wrong with it) and go direct to the API.

 

Jam off the boil

We’ve used the Jam package manager on a few projects now, and while it does have some advantages in dependency management and compilation it also uses its own module install system. So it relies on package owners keeping the versions that are published in Jam (rather than their main Github, etc, repo) up to date. We’ve had a few cases where the version of a library we needed isn’t available yet in Jam.

Jam interface with the browser is a modified version of Require, which we like for its clean module loading mechanism. So for future projects we’d look to dropping back to regular Require and find something else, perhaps a Grunt task, to handle the file concatenation and minification which Jam also offers.

 

App logic

The application logic required a fairly complex state to be maintained, and for these we used our old friend Knockout. We did consider lighter MV* libraries but ultimately felt that with Knockout’s very comprehensive view binding built-in we would save ourselves a lot of trouble. The other main aspect of the Javascript architecture was the use of a PubSub (publish-subscribe) library to communicate between the various parts of the app. So for example the AJAX API methods were fairly isolated – to enable their easy reuse – with their success states publishing the returned data for the viewmodels to pick up.

This decoupling did present a few edge case bugs around timing issues later on in development, but overall the ability to have communication, view state, preloading, sound and so on implemented independently and talking to each other via PubSub suited the Require modular loading we used as well as resulting in cleaner code.

This complexity of the application was borne out in the eventual size of the DOM, as we had several ‘pages’ within one document which were hidden and shown as required. For smoothness of experience this was useful, but retrospectively we’ve wondered if it might have been better to have a minimal HTML document with more extensive use of Javascript templating through Backbone or similar. Ultimately its hard to tell without implementing, but at least we have a steer for future iterations in this programme of projects.

 

Phonegap and other gotchas

It is well known that the performance of a web app wrapped in the Phonegap library is not as good as a native application.

Our previous Phonegap projects had a lot more DOM elements involved than this one so we hoped for better performance, but there were still a few performance issues on older iOS devices. Aside from that the Phonegap wrapping was pretty straightforward with minimal changes needed.

In the end perhaps the weirdest problem we discovered was that mobile service providers such as T-Mobile and Virgin appear to strip comments in HTML when sending data to mobile devices. This caused failures in our Knockout implementation, which used the library’s containerless control flow (i.e. specially formatted comments) to reduce the number of DOM elements – a very unexpected surprise. We ended up replacing all comment bindings with regular DOM bindings.

 

Device quirks – iOS[I] vs Android[A] vs Blackberry Z10[B]

- on-screen keyboard

[I] no viewport size change when hiding/showing the keyboard

[A, B] viewport size changes when keyboard is showing

[older A] even when the form page is hidden, the on-screen keyboard will not be dismissed unless the focus on the textfeld is forcibly removed.

- in-page scrolling

[A] even with overflow settings its still very buggy on the stock browser but Chrome doesn’t have problems.

- overflow: hidden

[older A] cannot interact with elements inside of “overflow: hidden” even if they are visible

- shake to undo (only on iOS)

[I] we found a filled-in form which was subsequently hidden triggered the iOS ‘shake to undo’ event. Unfortunately there was no known way for users to disable this feature easily but having an iframe somewhere in the DOM and changing its src (to anything) disables the “feature”. This hack doesn’t work if the app is wrapped in Phonegap but you can explicitly turn off shake to undo here.

- <audio> elements

[A] when a sound clip plays in an audio element it stops other background music from other apps

[B] the sound clip files are added to system playlist and so become accessible through its music player

- ‘devicemotion’ event

[A] on Android Chrome browser the ‘devicemotion’ event is not supported, although it is available on the stock browser. Future Chrome updates should add support.

- ‘orientationchange’ event

[older A] not supported

 

co-written by Stephen Fulljames

 

17
May
2013

Gmail Recipes – A Practical Approach to Learning Keyboard Shortcuts and Saving The World

by David Wynne

Red Badger recently switched away from Exchange Server to Google Apps and, after 5ish months, I can honestly say I think it’s one of the best decisions we’ve taken and we are collectively more productive because of it.

It was with some interest and surprise then that I was reading the hacker news thread last week about how Google have “ruined” Gmail with the latest tweaks. I guess I’ll preface this and say that until Red Badger moved to Google Apps I wasn’t a regular user of Gmail and so have pretty much learnt my way around based on the app as it stands now. I know a few long-time Gmail users in the Red Badger office have moaned about the new compose window etc, but I guess what you never had, you never missed and it’s never bothered me. I like it.

One of the books I’m reading at the moment, The Art Of Unix Programming, spends a lot of it’s time presenting the design patterns and ‘rules’ commonly used across Unix and the lessons we can take from those patterns to put into practice in our own development endeavours.

Three of these rules state that your application should be discoverable, transparent and obey the rule of least surprise, with the caveat that stuff can be surprising, so long as the first two rules are maintained such that those surprises are easy to learn. These three rule applied together often result in, the author argues, software that appears to be intuitive.

When I first read that, I guess I thought of Gmail. I always try to learn keyboard shortcuts to make my life easier and in doing so within Gmail I’ve found it incredibly intuitive. As a result I feel [random unprovable stat]% more productive dealing with mail and IM in Gmail than I ever did before.

Learning keyboard shortcuts can be a bit daunting. Obviously everyone can read the keyboard shortcuts, but my theory here is to present them in the context of common tasks (aka recipes) hopefully making them easier to pick up.  I’ve also thrown in a few modes of operating which, I hope, will help you learn a good chunk of the Gmail keyboard shortcuts and help save the world*.

Make sure you’ve enabled all the keyboard shortcuts first. Also I’m only noting down the Mac keyboard keys because I’m lazy and you can lookup the Windows keys yourself.

Empty Inbox

This is where all of this is heading. Aim to only have stuff in your inbox that you have to action. Everything else can be archived. That way when you start your day, or ask yourself “what next”, you should be able to carry out a Mailbox Triage starting from the oldest mail in your inbox regardless of whether you’ve read it before or not. Keep repeating the Mailbox Triage recipe until you have an Empty Inbox, or as close to it as is physically possible.

If I have more than ~15 emails in my inbox I’m not being ruthless enough or need to break out some common tasks to a Short Term Label.

Mailbox Triage

Start from the oldest email in the inbox, so that emails get treated in a first come first served priority order.

Open the oldest email in your inbox. Read it. Decide what action to take.
Respond. r to reply, a to reply all of f to forward.
Compose the message and hit Cmd + Enter to send.
If you want to apply a label, hit l + type the name of the label + Enter.
If no further action is required on the thread, hit } to move previous (ie. newer/up the inbox) and archive the current message in one fell swoop.
If further action is required, and you want to leave the mail in your inbox, hit k to just move previous.
Repeat until you reach the top message in your inbox.

The j and k keys move you next (older/down your inbox) and previous (newer/up your inbox).
The { and } keys move next and previous and archive the active message.

These two sets of keys alone save an epic amount of time and are the key (excuse the pun) to effectively triaging your mailbox.

Avoid using shortcut keys like v (for move message to label) – whilst useful, this will move the message to a label and return you to the inbox. The theory with this recipe is to remain in the current message, triage it and then move straight onto the next one until you’ve been through every email in your inbox.

Short Term Labels

Think of labels as being short term sorting pens. Ultimately you want to shepherd everything into Archive (and you’ll use search to find it again, if you need to… which you probably don’t), but labels are handy to get groups of actions out of your inbox and allow you to process them together at a later date.

For example, we’re on a recruitment drive at the moment so any CV that comes my way get’s labeled under ‘Recruitment’ and moved out of my inbox. When I have enough to process in one go, and the time, I can process them all at the same time (by applying the Mail Triage recipe), ultimately removing the ‘Recruitment’ label (and thus Archiving it) once I’ve progressed them to a natural conclusion. Once you’re finished with a label, remove it.

There maybe a few exceptions to this rule, but even as I look at my 1 long term label now, for product keys, I question if I really need it and couldn’t just as easily search for the product name when I wanted to find the key again.

If you have tons of long term labels, you lose the value of labels because you have to remember which label you might have applied when trying to find a message. Learn to use search.

Search

One of the reasons you can just Archive stuff in Gmail is that the search is so powerful. Anytime you want to quickly get hold of that email, hit / which will focus you into the search bar and start typing.

Most of the time you can use a keyword and find what you need, but there are lots of facets to help you be more specific.

Want to find something you sent? from:me
Want to find something that was emailed to Bob? to:bob@mail.com
Want to find something with a PDF attachment? filename:pdf

Moving Between Folders/Labels

Moving between the main folders (or system labels as they really are) in Gmail is simple, there are a number of g + key shortcuts, such as g + i takes you to the inbox (think ‘goto’ ‘inbox’). g + t slightly less obviously takes you to ‘sent’ items, being as g + s is reserved for taking you to ‘started’ messages.

Moving to custom labels is achieved via search. You could of course hit / and then enter ‘label:[your label name]‘ which is pretty quick. But even quicker is to hit g + l (‘goto’ ‘label’) and Gmail will pre-populate the search box with ‘label:’ for you. Enter your label name and hit Enter.

Once in a label, you can apply the same Mailbox Triage recipe until everything has been Archived and the label can be removed.

One Off Reply

For this to work you need to enable the “Send & Archive” button, within settings.
Use the up and down keys to focus the specific thread you’re interested in. Note the blue highlight, indicating which thread has focus. Hit Enter to open it.
Hit r to reply, a to reply all or f to forward.
Compose your message.
Hit Tab to focus on the Send & Archive button + Enter to action it.

Responding to an Older Message in a Thread

You’ve opened a message thread from your mailbox, and you want to go back up the thread and perhaps respond to an older message.

Press p to move previous/up the thread (older), n to move next/down the thread (newer). Note the blue marker indicating the selected message.
Hit Enter to open a message.
Hit r to reply, a to reply all or f to forward on the selected message.
Compose your message.
Hit Cmd + Enter to send.
If no further action is needed on the thread, hit e to Archive it. Don’t forget it will return to your inbox if anyone replies.
If further action is required and you want to leave it in your inbox, hit g + i to return to your inbox.

Moving/Labelling Multiple Messages

This is especially handy when, let’s say, you send out a meeting invite to a whole bunch of people and get lots of responses clogging up your inbox.
Use the up and down keys to focus a message.
Hit x to select the focussed message.
Move to the next message, hit x again. Repeat until all relevant messages are selected.
Perform an action, such as e to Archive them all. Or l to apply a label to them all.

If the action you applied didn’t move the message from the current view, they will still be selected. Hit * (shift + 8) and n to ‘select none’

The Interesting, but not Important

How long has it being hovering in your inbox for? Do you really need to read it right now? Archive it and search for it later when you have time/realise you needed to read it.

Hitting e on any message, from anywhere in your mailbox will Archive it.

Don’t Delete Anything

Unless you’re actually anywhere near to running out of space, why delete anything? (Apart from maybe emails from recruitment consultants or notification emails).

Chatting Whilst Doing Other Stuff

To start a new chat q + search for the contacts name + Enter.

If you complete the chat Esc to close and return focus to your mailbox.
If you want to leave the chat window open and deal with your mailbox, Shift + Esc and your mailbox will have focus.
Pressing Esc again will re-focus you back to your last active chat window.
Alternatively you can hit Cmd + , to focus the last chat window. This has the added benefit of cycling through all your open chat and compose windows, when continually pressed, allowing you to move between conversations.

What did I just press? What just happened?

Something unexpected just happened? Press z to undo the last action.

What keyboard shortcut can I use to do this?

Can’t quite remember the keyboard shortcut? Feel like you can probably achieve something with the keyboard instead of reaching for the trackpad? Shift + ? will bring up the keyboard shortcuts cheatsheet. I love this. It reminds me of the days when I was learning all of Resharpers keyboard shortcuts and used to have the cheat sheet taped to the desk in front of me.

That’s it – now go practice. It will take time, but I promise it will save you time and improve your life. Relatively speaking.

@dwynne

*Now you’ve got more time to help save the world instead of dealing with email!

25
Apr
2013

The Cynefin framework

by Arnaud Lamotte

 

“What distinguishes great leaders from average ones is their ability to perceive the emerging nature and rules of a game as they are playing it.” Brian Arthur

 

 Globalization, Technology and Information overload are making organizations, their environments and their activities more and more complex. For that reason, management science has turned toward complexity science to find appropriate models to help understand the challenges faced by organizations nowadays. An early conclusion of this approach is that managing complexity or managing in a complex environment requires specific sets of skills and tools.

I recently went to a seminar by Dave Snowden who has created a framework aimed at understanding the nature of contexts based on the relation between causes and effects, so appropriate tools are used and appropriate actions taken. This sensemaking framework is called the Cynefin framework. A Welsh word for a place where a being feels it ought to live. This blog is about what I have understood and gathered during that seminar.

 

The framework looks like a quadrant with two vertical sections, ‘ordered’ and ‘unordered’, and two domains per section, ‘simple’ and ‘complicated’ in ‘ordered’, and ‘complex’ and ‘chaotic’ in ‘unordered’. There is also a 5th domain in the center of the quadrant called ‘disordered’.

 

Cynefin Framework by Dave Snowden - cognitive-edge.com

Cynefin Framework by Dave Snowden – cognitive-edge.com

 

What is the nature of my system’s context?

In the ‘simple’ domain, problems and solutions are known. There is a one-to-one relationship between cause and effect. The connection between system components is strong and centralized.

In the ‘complicated’ domain, problems and solutions are knowable. Here knowable simply means that deeper investigations are needed, it is not obvious. There is a one-to-many relationship between cause and effect. The connection between system components is strong and distributed.

In the ‘complex’ domain, problems or solutions are unknown. There is a many-to-many relationship between causes and effects. The relationship between causes and effects can only be identified with hindsight, it is called retrospective coherence. The connection between system components is weak and distributed.

‘Chaos’ is the realm of the unknowable and feedback loops. Nothing makes sense.

Situations that do not fit in any of the above domains because of a lack of information or are in transition go into the disorder domain.

The above characteristics of each domain are not always easy to identify so Dave Snowden recommends the use of narrative techniques to help determine the nature of the situation.

 

What do I do?

In the simple domain, the right approach is ‘sense the facts, categorize them and respond’. Best practices, processes and autocratic management work very well in that domain.

In the complicated domain, the decision path is ‘sense the facts, analyze them and respond’. This is the realm of experts, good practice and systems thinking. Finding the right solution(s) can be time consuming in the complicated domain.

In the complex domain, solutions can only emerge, therefore the right approach is to probe first and then analyze and respond. While probing, the key is to find desirable patterns and ways to consolidate or amplify them. Iterative approaches are adapted. Rules that facilitate emergence replace processes.

In chaos, the decision model is ‘act, sense, respond’. Nothing makes sense and just observing may have consequences therefore it is necessary to act until the situation moves to another domain.

If a situation is in the disorder domain, it suggests that it has to be broken down into constituents that can then be allocated to other domains.

 

Where do I want my system to be?

The Cynefin framework is not a categorization framework; systems or situations can overlap different domains and move from domains to others. In fact visualizing these movements thanks to the Cynefin framework helps understand changes within systems. Furthermore there is no domain deemed to be intrinsically a better place to be than the others. However depending on the type of system under study some domains might be more adapted than others.

For instance being in the simple domain is not necessarily, rather counter intuitively, the best place to be for an organization because the risk of falling into ‘chaos’ due to complacency is very high. It is typically what happens when a corporate, not sufficiently aware of its environment, suddenly starts losing consequent market share because of a competitor disruptive innovation.

Organizations more often find themselves in the complicated or complex domain, or both which is perfectly fine as long as the tools used are adapted to the domain. The most common pitfall in these domains is ‘entrained thinking’ i.e. re-applying what has worked before, without ensuring that the ontology remains the same. The risk is particularly strong in these domains because the shift from one to the other may not be obvious although they are fundamentally different, one is ordered and the other unordered.

Finally, although corporates do not want to be ‘in chaos’, some Management gurus advise that organizations should try to set themselves at the edge of chaos to favor innovation. It may be a good punctual technique but probably difficult to maintain in the long run.

 

Logically, as the rise of complexity in organizations increases, so does the need for sensemaking capabilities. Sensemaking is now taught by the MIT Sloan School of Management as one of the four leadership capabilities alongside relating, visioning and inventing. With the Cynefin framework, Dave Snowden provides us with a tool to help us take the first step toward ‘making sense’ by understanding the nature of situations.

19
Apr
2013

Sorry Bootstrap, it’s over between us

by Stephen Fulljames

8658984467_0839741417_z

I’m sorry Bootstrap but things just aren’t working out between us. I think we should have a break from each other.

To be honest, it’s not me, it’s you.

When we first met I was kind of infatuated. You were so opinionated and successful, persuasive even, so many of friends couldn’t stop talking about you. It was easy to fall head over heels and looking back I think I let my heart rule over my head.

With you everything felt so straightforward. Prototyping was quick and easy. We put admin screens together in a snap, smiling and laughing the whole time. I began to think there was nothing you couldn’t do, I started to let you lead me.

But then I looked around and realised you’d been seeing other people. It was a real shock.

Everyone was starting to think the same way and it was all because of you. You made such a compelling case for the way that things should be that everyone, myself included, just kind of went along with it. Looking back I realise now that you were too controlling. If a great design didn’t quite fit to the way you wanted to do things, I would just change it to make you happy. It was a lot easier.

Then I came to realise, that wasn’t what I wanted after all. I mean, the designers I work with really know what they’re doing. They’re the ones I should listen to first, and if you can’t help me in the way I need you to then I guess it’s time to move on.

I got on just fine before you came along, and I know that I can get back to how things used to be without you. I’m sure I’ll be happier out there on my own, CSS is a wide world and there’s new stuff to see all the time. I just think I’d rather make those discoveries for myself rather than have you colour them.

Don’t be sad, Bootstrap, I’m sure you’ll find someone else. Just be good to them, okay?

Photo: prorallypix, Creative Commons licenced.

 

16
Apr
2013

How can we nurture a great designer at tech start ups?

by Sari Griffiths

How can we attract talented graduate designers? Can we be a serious contender in the design industry?

The traditional (or conventional) wisdom says the best place for graduates to learn their trades is at successful creative agencies or consultancies. But is it possible for tech start-ups to nurture design talent too?

I took a (very subjective and personal) look at pros and cons of options from a graduate’s point of view to see if joining the start-ups can be a viable option for them.

Pros and cons of established medium to large design agency or consultancy

Pros:

  • There are many peers you can learn from – a team or teams of designers who compete and inspire each other (in theory, at least)

  • There is a variety of work going on, giving you wider insight.

  • Higher possibility of doing projects for large, well-known brands

  • Longer term projects allow you deeper understanding of brands

  • Design is at the heart of the company

  • Large alumni network can help you in the future. Or add some kudos in your CV.

Cons:

  • Smaller part / say / influence in a project (you will probably have to be very assertive to be noticed) to begin with

  • Pay is often linked to a job title – okay for the first few years but it will become increasingly painful as you reach senior positions

  • More office politics (just because there are more people…)

  • Tendency to design for the peers and awards

  • Less disruptive in general

Other characteristics:

  • Many processes and templates to follow

  • The projects tend to be longer

Pros and cons of tech start-ups for designers

Pros:

  • Greater responsibility, influence and contribution as there are generally less people

  • Early exposure to clients

  • Get to see the end results quickly

  • Multi disciplinary team environment for insights and inspiration

  • Emphasis on great user experience

  • Likes to be disruptive

Cons:

  • As it tends to be small you have less peers to learn from. The worst case scenario is you could just get thrown into the deep end without any support.

  • The projects tend to be for smaller clients. (Having said that, more and more large enterprise are seeking out start-ups for innovative solution as you can see from our client list)

  • The projects tend to be shorter with less time for crafting design

  • Less emphasis on design

Other characteristics:

  • It’s usually small

  • The projects tend to be shorter 

So, what can tech start-ups do?

1. Invest on support

You will need good senior designers who are willing to help others to begin with. If you do, then the small setting is actually a positive thing as graduates can get more personal, hands on attention.

Make sure training is provided and appropriate tools are available. There might not be many peers inside the company, but there are millions out there in some form of on- and offline communities. Join up.

2. Promote user experience

While visual design might not be at the heart of the company, the user experience should definitely be, alongside technology.

Visual design (including branding) is basically the physical manifestation of user experience. It can’t be ignored. Even if the technology works well, if it fails to communicate and be usable, no one will use it or identify with it. It’s not just about making things look pretty. It’s vital that you get the design right.

You also need to understand that design is something constantly evolving and improving. Let’s try not to call that jpeg “FINAL”…!*

*Dear graduate readers: You will soon encounter a filename that ends with “FINAL FINAL FINAL” or “NEW NEW NEW” when you start working. Someone has obviously been very optimistic.

3. Be disruptive and cutting edge (and fun)

This is the biggest advantage start-ups have over bigger, more established firms. You are more agile and flexible, and you can be more disruptive.

Any designers can make difference, create something new from day one. Surely that is very motivating.

Fun and creative and nurturing

4. Inspire

Working within a multidisciplinary team can inspire designers in a different way from a team of designers. It is not about designs for designs sake. It’s the art of looking sideways in a sense.

In the bigger firms, especially those that operate with a waterfall methodology, sometimes you don’t even get a single opportunity to talk to a developer during a project.

Start-ups should create an environment that encourages all the team members to communicate – if you are running in agile that incorporates UX and design properly (If you’re interested in how to do this, here is my previous blog: Agile Survival Guide for Designers), then that should happen naturally.

Are you a graduate?

There is a lot happening with design in tech start-ups right now. It feels a lot like 1960s was for graphic design. There are opportunities to innovate and experiment. While I agree that there are loads you can learn from being surrounded by designers, surrounded by developers and other disciplines enables you to achieve something equally exciting, and potentially new and groundbreaking.

Maybe you need a bit of entrepreneurial spirit and drive to improve. And a love of creating something you can be proud of. It’s more about what you create and do, rather than what other people think you do.

I am not saying all the tech start-ups are great place for a budding designer. But as long as they hit the four points I listed above, I think they can be a great place to be. Maybe more than what the traditional wisdom says. If you are a graduate / budding designer and interested in working with us, please give us a shout at hello@red-badger.com.

(If you’re interested in seeing the Lego plant pot being made, here is the stop motion animation I made while building it. And it’s inspired by Being Geek Chic blog.)

4
Apr
2013

The Science of Buoyancy

by Cain Ullah

Screen Shot 2013-03-27 at 17.48.34

In March, I went to see Dan Pink discussing the “The Science of Buoyancy” at one of the consistently excellent Intelligence2 debates.  The subject of buoyancy is one that Dan has explored in his recently released book, “To Sell Is Human”.  A text that uses selling, ultimately as an example to describe human nature.

Dan describes buoyancy as a quality that combines grittiness of spirit and sunniness of outlook, and this will form the basis of my post. I’m going to highlight the points that Dan covered in this area, and conclude with some considerations for how you might also help to keep your employees “buoyant”.

We Are All In Sales

Napoleon Dynamite SalesDan Pink’s previous book “Drive”, raised some points, asking how motivation works in a sales environment. The response to “Drive” got Dan Pink interested in Sales and “To Sell Is Human” is the result of his research. 1 in 9 people are in sales jobs in America but Dan argues that we are all in sales, despite the role of a salesman often having a negative stigma in our mind (We’ve often seen salesman portrayed as slimey, manipulative creeps in movies – see apt screenshot from Napoleon Dynamite!). 

Research has shown that on average, 41% of our time is spent on what he calls non-sales selling. By this he means, convincing, persuading and influencing others to do things we want them to. This opens us all up to the environment and/or response that salesmen are used to and in an adapting digital world where information is at our fingertips, we have also switched from a “buyer beware” market, to a “seller beware” market. In other words, a salesman no longer has the benefit of having the advantage of knowledge that the buyer doesn’t have. As a result, Dan Pink recommends a change in the foundational qualities of selling, with ABC (“Always Be Closing”) taking on new meaning to now represent “Attunement, Buoyancy and Clarity”. And as we’re all salesmen, whether we like it or not, this affects us all.

Attunement is to bring things into harmony with individuals, groups and contexts. i.e. Can you see the world from someone else’s point of view rather than your own? Having a sense of power reduces your ability to have a sense of perspective. So reducing your feelings of power can improve your acute perspective abilities. It is more analytical than empathy, looking at things such as strategic mimicry and practising to be an ambivert. Extraverts rarely make the best salesman and a buyer is now more likely to buy from someone they like.

Clarity is all about making sense of murky situations. It’s providing clarity to your prospect by asking certain irrational questions in a structured way, curating your questions and information well to make it accessible. It’s also not necessarily trying to offer to fix problems that your prospects already know they have, but rather finding problems they did not know they had.

If you want to find out more about Attunement, Clarity and the rest of the contents of “To Sell Is Human” I would recommend you buy it. It’s an excellent read. Now to discuss Buoyancy…

Buoyancy

Chapter 5 of the book and Dan’s talk at Intelligence2 are focused on buoyancy. The line of research takes learnings from social psychology on how to bounce back from rejection. Dan uses sales as an example to illustrate his research as it is a role in life that has a great deal of rejection to deal with. However, the same principles can also be applied to everyday life, when you are rejected in the process of trying to convince someone to do something. Dan quotes Norman Hall’s phrase – “Every day you get up and face an ocean of rejection”. Buoyancy is how you stay afloat on that “ocean of rejection” that Hall talks about.

The research on buoyancy is split into what you do before, during and after an encounter.

Before an Encounter

Dan bases some of his research on what to do before you enter an encounter on Delores Albarricin’s work. Self help gurus will often tell you to think positive, affirmative, be bullish. Say to yourself “I can do this!”. The research actually shows that this is not the best approach. Phrases that ask a question such as “Can I do this?” rather than “I can do this” are far more effective.

Albarricin calls this “Interrogative Self-Talk”. Questions by their very nature illicit an active response whether you’re talking to yourself or to someone else. It prepares you for the encounter and forces you to rehearse. You prepare more thoroughly and are thus stronger than the more bullish declarative self-talk despite the latter sounding stronger.

During an Encounter

During an Encounter is all about “Positivity”. Someone is far more likely to be influenced by someone with a positive affect even if the subject matter is unchanged. So how do you make sure you have a positive affect?

Barbara Fredrickson’s research shows that positive emotions open us up. They broaden our actions, open awareness to a wider range of thoughts and make us more receptive and creative. Fredrickson worked with a Brazilian mathematician, Marcial Losada, to help her discover that affectiveness and flourishing occur when positive emotions outway negative emotions at a tipping point of roughly 3:1. A ratio of 2:1 is no different to 1:1 or entirely negative emotions.

To monitor your positivity ratios you can start by visiting Barbara Fredrickson’s website www.positivityratio.com. As well as this, there are certain positive emotions you should try to be more conscious of – joy, gratitude, serenity, interest, hope, pride, amusement, inspiration, awe and love. If you select a couple (E.g. Take ten minutes to think about three things you are grateful for) and look for ways to display them, it can have a profound effect on your positive affect and thus enable you to better influence people during encounters.

Note: Check out Fredrickson’s book for more in-depth insights into her research.

After an Encounter

The best predictor of success is how you explain failure. Martin Seligman, a professor of psychology at the University of Pennsylvania has demonstrated through research that Explanatory Style in explaining negative events has an impact on our buoyancy. The best way to do this is to ask yourself three questions and to construct an answer “no” to each. The three questions are: Is this personal? Is this pervasive? Is this permanent? 

So, if you have just lost a bit of business in a pitch what might you ask yourself?

  • Is this personal? i.e. Was there something wrong with the way I presented? Example Answer: No. The presentation could have been better, but the company just wasn’t ready to buy just yet.
  • Is this pervasive? i.e. Is everyone I visit going to reject this particular pitch? Example Answer: No. This particular company just didn’t have the vision to see the value. Another company probably will.
  • Is this permanent? i.e. Have I completely lost my skill for selling? Example Answer: No. I just had a bad day. I was tired. The next will be much better.

The more you explain bad events as temporary, specific and external the more likely you are to persist. This is an analytical way of improving your buoyancy and thus improving your likelihood at being a better salesman in the future. This is not to say that you shouldn’t look for holes in your presentation, take learnings from the feedback from the client and try to improve your pitch for the next time. It is not delusional. It is learned optimism.

If you go too far on the side of positivity (above and 11:1 positivity ratio to be precise), you might consider yourself to be in la la land! It is important not to be in denial. Using some of the methods above will help you get the balance right between levity and gravity to reach the optimum buoyancy. If you de-catastrophy things in a methodical way, it can make you more effective in sales and more effective in life. 

The lovely term coined by Seligman is “Optimism with its Eyes Open”. Perhaps we should all start practising it.

Helping your employees stay buoyant

I haven’t yet tested the theories set out in the book for my own personal well being. However, as a business owner I am interested in not only my own well being in doing my job, but also the well being of my employees.

Feedback

One of the main reasons I like to attend talks such as Intelligence2 is that you get to interact directly with the likes of Dan Pink to see if he can provide you with some insights specific to your questions. Being at the talk gave me the opportunity to ask how you stay buoyant if you lose out in a competitive environment (E.g. a pitch for some business against other businesses) but you are ignorant as to why another pitch may have been chosen above yours. Dan’s response was that this is a feedback problem, not a buoyancy problem. This question raised an interesting topic about feedback both from your client prospects but also internally in an organisation and how it can influence buoyancy.

A common problem is that people in the workplace don’t necessarily have a sense of how well they’re doing. Research in the field of talent by Teresa Amabile, professor at harvard business school, shows that employees are most happy when they feel like they are making progress in meaningful work. But making progress is dependant on rich, regular, feedback.

For feedback, an annual performance review just doesn’t cut it. We don’t do performance reviews at Red Badger or any performance linked bonus but rather a quarterly one-to-one meeting with each employee that is informal but basically provides encouragement by telling them what they are doing well, discusses where they could improve and also asks how we can improve to help them and what their ambitions are (what they want to get involved in etc…). We also supplement this with a more agile, informal but constant programme of feedback that is project specific. It’s basic common sense but something that is all too often, easily overlooked.

For your own buoyancy when trying to sell to prospects, it is equally important to demand as much feedback from them as possible so you can implement the above factors, learn where you went wrong, iteratively improve and stay buoyant.

Teams

So what is the right balance inside a team? Should you have a team of all optimists? What about grouping people who work well together historically? 

Brian Uzzi has done some interesting research on teams and came to the conclusion that having a team of people who have always worked together doesn’t produce the best results. Equally, having a team of people that have never worked together doesn’t either. The most optimum teams are a mix of people that have worked together a lot and some who haven’t worked together. This keeps the team both dynamic and coherent, producing the best results. 

Whether you want to mix the team up to include a 3:1 ratio of optimists to pessimists I don’t know. This sounds like an incredible challenge with no quantifiable research showing whether it will provide any benefit. But it’s some food for thought.

Conclusion

This doesn’t feel like the answer to all things. These techniques are not going to help you win business alone. You’ll need to iteratively improve your ways of working (using feedback and experience to help you), pitches need to be on point and appealing to the prospects, opportunities need to be qualified properly and all of the other basic practices of business development need to be in place. However, a pitch is also very creative. It paints a vision. Practicing the above techniques can put you in the right frame of mind to make you more creative, helping to build a better pitch but also help you have more influence over those you are trying to persuade. Inside a company, the precursor to this is to provide better, more constant feedback, change up teams, keep things new and different for your staff and present them with new challenges and that will give them the tools to manage their own buoyancy.

Outside of business, these techniques may also allow you to lead a life with a greater sense of fulfilment. 

Time to start working on the interrogative self-talk, positivity ratios and explanatory style…