Wednesday, 19 June 2013

Skimmer's Guide - Behaviour Driven Development with JavaScript

“BDD has many different aspects. Which of them are important depends on your perspective.”


Marco Emrich brings us a mature and enlightening insight into Behaviour Driven Development with JavaScript. Absolutely rammed full of excellent information, the book is nevertheless extremely well paced and reads very easily.

Beginning in earnest with a quick refresher on JavaScript, we are soon introduced to Jasmine, our JavaScript BDD weapon of choice ;) The underlying mechanics of BDD are explored (i.e. Red-Green-Refactor) before we are shown novel ways of generating data for our tests.

Particular attention is then spent on advising us how to organise/write our tests to maximise readability/maintainability. Following this we dive into Outside-In Development and how we can use it to flush out uncertainty. Use cases of the various types of 'test doubles' are covered, extensively so for mocks.

We finish by addressing the difficult question of "what is BDD?", bringing together everything we learnt into a formal methodology. The most important aspects are brought into focus and pointed in the direction of possible next steps into the BDD world.


JavaScript refresher (p. 7) 
Covering modern and functional aspects of JavaScript, this introductory chapter is incredible helpful for anyone rusty with JavaScript. Anyone experienced in JavaScript should probably simply skim/skip this though. 

Specs should be readable (p. 27) 
Great coverage of the DAMP/DRY principles here and throughout the chapter. Sound advice with warnings every developer should heed! 

Organising by feature or by fixture (p. 35) 
Interesting techniques for keeping tests cohesive and making them read naturally, through intelligent organisation and custom code tools. 

Using test doubles (p. 53) & Advantages and disadvantages of mocks (p. 61) 
Fantastic coverage on how and when to use dummy, stub and mock objects, including views on the pros and cons of mocking. 

Vocabulary (p. 61) 
A resonating account of the pitfalls of TDD for beginners and how an improved vocabulary better enables proper testing. 


Baby Steps (p. 23) 
Wonderful teaching on the importance of having a "tight feedback loop". Emphasis it placed on how the longer it takes to find a problem, the harder it is to solve it. Taking baby steps when changing code will let you go faster! 

Triangulation (p. 42) 
A wonderful technique for "faking it until you make it", forcing you to test all the relevant paths through your code. 

Gerkin language (p. 66) & Goals and benefits (p. 67) 
Covers the fabled "Given Then When" syntax of BDD and how it isn't necessarily central to BDD.


At less than £2.60 ($3.99) this book is insanely good value and I would highly recommend it to anyone starting to learn BDD, even if they have limited JS experience. Despite centring around JavaScript, the core concepts of BDD are covered magnificently and can be applied to any language. 

Highly accessible and easy to reference, this book definitely warrants inclusion on any developer's digital bookshelf.

Saturday, 1 June 2013

Epiphany Of Ignorance

As you can tell by the plethora of updates recently, I have been busy beavering away on various projects and interests. Recently some revelations have really struck home and I've come to realise the vastness of my own ignorance. Here is a random selection of them :)


Confidence, or the lack of it, has been a major issue for as long as I can remember. Recently I have been effectively devoid of it, for no real good reason. For this reason I really have to focus on getting back in touch with my own innate abilities. This means trusting in myself and striving to realise my real potential (thanks to Kenric, Barry and Matt for helping me see this)!


Fooling yourself is an easy thing to do though, I need to know my current limitations. As I learnt the hard way, cargo cultism can creep up on you without you even knowing it. My experience of TDD up to now was very much limited to using it as a tool for catching bugs and evolving established designs. When it comes to using Test Driven Design to rapidly build clean code out of uncertainty, my fundamentals just aren't quite polished enough yet (thanks to Sandro and the LSCC for enlightening me)!

Basic Mastery

Sweating the small things can actually be really important, in my case mastering the basics is fundamental to building a strong foundation. There are so many metaphors and allegories I could use for this, my favourite is from Bruce Lee:

"Before I learned the art, a punch was just a punch, and a kick, just a kick. After I learned the art, a punch was no longer a punch, a kick, no longer a kick. Now that I understand the art, a punch is just a punch and a kick is just a kick."

Right now I am still working hard on learning... One of the best lessons I have learnt so far goes hand in hand with mastering the basics and that is the "Single Responsibility Principle". This applies to so many things in life, it is better to be an expert at one thing than to do many things badly (many thanks to Ben and Martijn for showing me the light on all of this)!


Practice really does make perfect. Not just any practice though, you really have to practice perfection. Getting it wrong is fine but it is always important to remember practicing is not for getting it right, it is for never getting it wrong. For instance, you practice arithmetic so you can practice calculus without worrying you got the basics wrong (thanks to Nigel for this, may you guide me for years to come)!

Faster Feedback

Achieving a long-term goal isn't done by doing a long task over time and slogging it out. Fast feedback is critical. This means doing things successfully consists of doing smaller things which aim you the right way and more importantly can tell you if you are succeeding (thanks to Kevlin for sharing the time to inspire me, you're simply awesome)!