Web Development
-
JavaScript. But less iffy.
Written by James SinclairHave you ever started writing some code that seemed so simple? But then you had to validate the input? And handle an edge case? Oh yeah, and that weird thing the server sometimes does? And somehow this oh-so-simple piece of code turned into a mess? This article looks at how we can reduce the complexity introduced by conditionals.
-
JavaScript Without Loops
Written by James SinclairWe’ve been talking about writing less complex JavaScript. We do this by choosing the right abstraction to solve a problem. But how do you know which abstraction to use? So far, we haven’t looked at any concrete examples of how to do this. In this article we look at how to deal with JavaScript arrays, without using any loops. The end result is less complex code.
-
Indentation is the enemy: Writing less complex JavaScript
Written by James SinclairI’ve been working a lot with a legacy code-base lately. And this one is particularly troublesome. It has all the hallmarks of a rush job. The code is brittle. There are no tests. Things often seem to break at random. And to my embarrassment, I wrote most of it. So, I’ve been thinking about how I ended up here. How did the code get so intertwined and brittle? And how do I prevent it in future?
-
The Marvellously Mysterious JavaScript Maybe Monad
Written by James SinclairMonads have a bad reputation in the JavaScript community. Douglas Crockford even said that monads are cursed: Once you reach enlightenment and finally understand monads, you immediately lose the ability to explain them to others. Even amongst experienced functional programmers, monads are treated with respect. But, if you can understand Promises then you can understand monads.
-
One weird trick that will change the way you code forever: JavaScript TDD
Written by James Sinclair‘One weird trick’ is a cheesy title, I know. Originally I was using it as a draft placeholder title for a joke. But the more I thought about it, the more it seemed appropriate because it’s true. Test Driven Development is one weird trick that will change the way you code forever. It will make you a more badass developer.
-
TDD Should be Fun
Written by James SinclairSometimes TDD can seem like a drag. Are you writing mocks that are several times more complicated than the code you will test? Does your test suite take minutes (or hours) to run? Does refactoring your code fill you with dread because of all the tests to rewrite? If any of this sounds familiar then it may be time to try a new strategy.
-
A Gentle Introduction to Javascript Test Driven Development: Part 3
Written by James SinclairThis is part three of a three-part series outlining my personal approach to JavaScript TDD. Testing code that creates HTML and manipulates the DOM can be tricky—especially when testing without a browser. In this article I outline one approach to this, and finish off the sample application we have been building through the series.
-
A Gentle Introduction to Javascript Test Driven Development: Part 2
Written by James SinclairWorking with JavaScript network calls can be tricky when practicing Test Driven Development. This article gives an example of how to use stubs and Promises to make testing network calls easier. This is part two of a three-part series outlining my personal approach to JavaScript TDD.
-
A Gentle Introduction to Javascript Test Driven Development: Part 1
Written by James SinclairGetting started with test driven development (TDD) can be daunting. It sounds tedious, boring and hard. There’s also a confusing array of frameworks and libraries out there. Some work on the server; some work in the browser; some do both… it can be hard to know where to start. This is part one of a three-part series outlining my personal approach to JavaScript TDD.
-
A Gentle Introduction to Functional JavaScript: Part 4
Written by James SinclairIn the last article of our four-part introduction to functional programming in JavaScript, we looked at higher-order functions. In this article we discuss how to use these new tools with style.