Using Decorators to Declaratively Extend Functions

The decorator pattern gained fame in the object-oriented world after being featured in the classic 1994 Gang of Four book, Design Patterns. Since then, it’s been used extensively in traditional object-oriented programming as an alternative to inheritance. What’s really going on behind the scenes though, is composition, which means decorators are also great for cleaning up some functional programming boilerplate.

We’re going to look at decorators in JavaScript, along with some proposed syntax sugar coming in ES2017 that will make it easier to use them. Read more on Using Decorators to Declaratively Extend Functions…

Factory.ts: A Factory Generator for Test Data Using TypeScript

I’ve been using TypeScript on a React/Redux project, and I’m really enjoying it.

A year and a half ago, I tried to use TypeScript with an Angular project, and I found that it didn’t add that much. But with version 2.0 and on, TypeScript has really come into its own. Structural typing allows you to express concepts in TypeScript that I’ve never been able to express before. In particular, mapped types are just insanely useful.
Read more on Factory.ts: A Factory Generator for Test Data Using TypeScript…

Building Better Board Games with Clojure and Gorilla REPL

A while back, my six-year-old daughter and I were on one of our regular daddy-daughter date nights when we decided to create a board game. We sat at a restaurant table with paper, crayons, and a small collection of Dungeons and Dragons trinkets. To my surprise, we built a fun little game that my daughter named Turtle Burglars.
Read more on Building Better Board Games with Clojure and Gorilla REPL…

4 Tips for Thinking Functionally

I’ve written before about why I prefer a functional programming paradigm to an object-oriented one, but it’s taken a long time to get there. I dabbled on and off for half a decade before the core ideas behind Clojure and Haskell really sank in and I could write code in my head without having to sit at a computer.

My relationship with functional programming may have been slow, but it was punctuated by several key insights. These deeply altered my approach to designing code, even code in non-functional programming languages.

Here are four habits that dramatically shifted my thinking toward functional programming.
Read more on 4 Tips for Thinking Functionally…


REPLs (Read-Eval-Print-Loops) are often billed as a great place to experiment and learn a language or a framework. They provide a very tight feedback loop. However, it can be difficult or time-consuming to extract the knowledge gained from a REPL and include it in your source code. I’ve hit the up arrow many times in Ruby’s pry, trying to find the specific input I wanted to copy. And don’t get me started on dealing with multi-line input. Thankfully, the developers behind F# came up with a clever way of dealing with this problem. Read more on TDD in a REPL…

Four Reasons to Use Maps Instead of Classes

I started my career back when Object-Oriented Programming was first becoming a dominant methodology, and boy, was OOP going to change the world. Encapsulation, inheritance, polymorphism—these tools promised to save the righteous from complexity, guarantee reusability, and decouple all the things!

So when I recently starting developing in Clojure, the suggestion to “just use maps to represent data” gave me pause—how could maps be better than objects? Heresy! I’ve since fallen in love with the approach, and would like to share four reasons why.

Read more on Four Reasons to Use Maps Instead of Classes…

RSchema-Hamster: Schemas for Shaping Immutable Data

RSchema-Hamster is a Ruby gem that lets you use Hamster’s persistent data structures to define and validate the shape of your data via RSchema.

What for?

In order to clarify my designs, reduce mistakes, and leave code easier to change than when I found it, I:

Read more on RSchema-Hamster: Schemas for Shaping Immutable Data…

Elixir Native Interoperability – Ports vs. NIFs

Lately I’ve been working on a personal project of creating a wireless sensor network across my home. Elixir is a perfect fit for this project, but I quickly hit a road block: serial device access. While there are Erlang serial libraries that I could use, I wasn’t ultimately comfortable doing so, due to many forks and adding yet another layer of complexity. Read more on Elixir Native Interoperability – Ports vs. NIFs…

More Typing, Less Testing: TDD with Static Types, Part 2

In part 1 of this post I claimed it’s easy to test-drive our way into a poor design. We looked at some techniques for using types with TDD, but the examples were simple. Today I’ll walk through Kent Beck’s Money example showing where the design fails and how it can be improved with types. Read more on More Typing, Less Testing: TDD with Static Types, Part 2…