Another Perspective on Promises

I spent 9 months of this year working on a project using Java 8 and enjoyed it much more than I expected. Specifically, the addition of Optional made my code feel cleaner, more functional and less error prone. I had Java 8 on the brain when I tackled a small JavaScript project a few weeks ago. After finishing it, I decided to go back and try it again using Promises. I was immediately struck by how similar Promises are to a cousin of the Optional – Result....

December 28, 2016 · Drew Olson

Specify Your API

Much of the past 6 years of my professional life has been spent designing, implementing and maintaining APIs. I’ve learned many things to avoid as well as a handful of good techniques. However, it wasn’t until 3 months ago that I was exposed to a practice I consider the most important thing you can do while building APIs. Every production-quality API I build going forward will be rigidly and explicitly specified....

August 5, 2016 · Drew Olson

Extensible Design with Protocols

I wrote some code this week that reinforced the power of protocols as a tool for software design. The term “protocol” can mean many things in the world of software. Let me clarify that I’m using protocol to mean the mechanism used by some languages (Elixir, Clojure, etc) to achieve polymorphism. Used properly, protocols allow you the provide users of your code with a set of standard behavior as well as a clear contract for implementing that behavior on standard or custom types....

March 19, 2016 · Drew Olson

Elixir Streams

I previously wrote about explicitness in Elixir. One of my favorite ways the language embraces explicitness is in its distinction between eager and lazy operations on collections. Any time you use the Enum module, you’re performing an eager operation. Your collection will be transformed/mapped/enumerated immediately. When you use the Stream module, you’re performing lazy operations. The Stream module provides many of the same operations as Enum, but when used with Stream they’re describing future computations rather than actions to be taken immediately....

June 8, 2015 · Drew Olson

Sanity Tests

It is common for test “classifications” to have a plethora of definitions. Sanity tests are no different. Wikipedia says the following on the subject: the sanity test […] determines whether it is possible and reasonable to proceed with further testing. This implies that a sanity test is some sort of “pre-test” to determine if further testing even makes sense. I, however, think of sanity testing as breaking the fourth wall of the codebase....

May 29, 2015 · Drew Olson

The Value of Explicitness

Elixir is often compared to Ruby. It’s true that Elixir takes inspiration from Ruby’s syntax. One of Elixir’s core tenets is “metaprogramming”, something often associated with Ruby and its ecosystem. That said, after using Elixir for a small amount of time it is immediately obvious that the semantics of the languages are very different. More subtly, Elixir focuses on explicitness where Ruby is often implicit. In this blog post, I’ll discuss Elixir’s approach to composing functionality in an explicit manner....

April 3, 2015 · Drew Olson

An Empathetic Functional Language

I’ve been writing Elixir code for over a year. Never have I been more excited about the prospects of the language and its community. The language is young but very promising. Many smart people are getting involved. There’s a hell of a trajectory here for a language that released 1.0 merely 6 months ago. I’ve been wondering what is it specifically about Elixir that has pulled me in and prompted my involvement in the community....

March 20, 2015 · Drew Olson

Pagination with Phoenix & Ecto

I’ve been working on a web application built in Elixir. I’m using Phoenix as the web framework and Ecto to talk to my database. As the amount of data in the application grew, I needed to paginate some of the views. I wasn’t able to find an existing pagination solution for these tools so I ended up building my own. This post will discuss what I built. Goal Once we’re done, we should be able to paginate any Ecto query using parameters provided by a Phoenix controller action....

February 20, 2015 · Drew Olson

Composable Queries with Ecto

In my previous post I briefly covered some lessons I’d learned while building a (kind of real) web app in Elixir. Today, I’d like to take an in-depth look at composable queries in Ecto. First, a brief introduction to Ecto. What is Ecto? I think of Ecto as a light-weight ORM. Ecto uses Elixir structs to represent database tables and provides a DSL for building and executing database queries. Because I’m boring, we’re going to use the ages-old “post has many comments” example to demonstrate Ecto’s capabilities....

January 23, 2015 · Drew Olson

Building an Elixir Web App

Over the past few months I’ve been building a small internal application at work. I’ve been using Elixir, Ecto and Phoenix and it’s been an absolute blast. I thought it would be useful to put together a “lessons learned” blog post about the techniques I’ve found helpful using these tools to build a database-backed web app. This post is not intended as an introducion to any of the these tools. I assume some knowledge of Elixir, Ecto and Phoenix....

January 19, 2015 · Drew Olson