Side by side

This week marked my first year at my current employer. While that event went by rather silently, one year in, a few of my observations are finally shaping up to be cast into writing. Where I used to work in the typical battery cage, I’m now part of a team of just four people, having the luxury of a big dedicated room to ourselves - a whole floor actually. The room is set up almost symmetrically; two desks on one side of the room and two more on the other side, with quite some space in between. Having only four people in the room makes it easy to casually throw something at the group - be it a question, a critique or a random idea. ...

February 15, 2015 · 3 min · Jef Claes

Averages are not good enough (F#)

Let’s (no pun intended) look at a set of response times of a web service. let responseTimes = [ 18.0; 21.0; 41.0; 42.0; 48.0; 50.0; 55.0; 90.0; ] People like having a single number to summarize a piece of data. The average is the most popular candidate. The average is calculated by dividing the sum of the input elements by the number of input elements. let average input = let length = input |> Seq.length match length with | 0 -> raise <| new ArgumentException("Input sequence is empty") | _ -> (input |> Seq.sum) / float length // Average = 45.625 // (18 + 21 + 41 + 42 + 48 + 50 + 55 + 90) / 8 The average is a measure of centre which is fragile to outliers; one or two odd irregular values might skew the outcome. The median on the other hand is always representative of the centre, not just when the data distribution is symmetric. The median is determined by sorting the input elements and picking the one in the middle. ...

January 18, 2015 · 4 min · Jef Claes

Consumed in 2014

Starting 2014, I wanted to look more closely at everything I consume. So I started keeping a list of everything I read, watch and listen to. I started off with a markdown file on Github that quikcly evolved into a good excuse to dabble with an alternative stack. I ended up writing an event sourced node.js application on top of postgres, hosted on Heroku. I could write a post on that particular experience, but it’s safe to say this blog post captures it better than I ever could. ...

January 11, 2015 · 3 min · Jef Claes

TDD as the crack cocaine of software

The psychologist Mihaly Csikszentmihalyi popularized the term “flow” to describe states of absorption in which attention is so narrowly focused on an activity that a sense of time fades, along with the troubles and concerns of day-to-day life. “Flow provides an escape from the chaos of the quotidian,” he wrote. This is a snippet from the highly recommended book Addiction by Design, which not only gives you an incredibly complete overview of the gambling industry, but also insights into the human psyche which apply far outside the domain of gambling. ...

December 28, 2014 · 4 min · Jef Claes

Spinning the wheel: clustering and near misses

The previous post showed a simple model casinos use to manipulate the odds. Instead of relying on the physical wheel for randomness, they rely on a virtual list of indexes that maps to the physical wheel. Using that same model, it’s easy to fiddle with the virtual indexes so that they map to misses right next to the winning pocket, creating “near misses”. “Near misses” make players feel less like losing, since you “almost won”. Casinos use this technique to get the next spin out of you. ...

December 14, 2014 · 2 min · Jef Claes

Spinning the wheel: manipulating the odds

The previous post defined a basic set of data structures and functions to spin a wheel of fortune in F#. There was very little mystery to that implementation though. The physical wheel had four pockets and spinning the wheel would land you a win one out of four spins. As a casino, it’s impossible to come up with an interesting payout using this model. To juice up the pot, casinos started adding more pockets to the wheel of fortune. This meant that the odds were lower, but the possible gain was higher. More pockets also allowed casinos to play with alternative payouts, such as multiple smaller pots instead of one big one. ...

December 11, 2014 · 2 min · Jef Claes

Spinning the wheel

In this post, I’ll define a basic set of data structures and functions to spin a wheel of fortune. In the next post, I’ll show you the simple model casinos use to build a bigger, more attractive pot, without touching the physical wheel and without losing money. Finally, I’ll show you how casinos tweak that model to bend the odds and create near misses. Let’s say we have a physical wheel with four pockets, which are labeled either miss or win. ...

December 9, 2014 · 2 min · Jef Claes

Hot aggregate detection using F#

Last week, I wrote about splitting a hot aggregate. Discovering that specific hot aggregate was easy; it would cause transactional failures from time to time. Long-lived hot aggregates often are an indication of a missing concept and an opportunity for teasing things apart. Last week, I took one long-lived hot aggregate and pulled smaller short-lived hot aggregates out, identifying two missing concepts. Hunting for more hot aggregates, I could visualize event streams and use my eyes to detect bursts of activity, or I could have a little function analyze the event streams for me. ...

November 16, 2014 · 2 min · Jef Claes

Splitting hot aggregates

When you visit a real casino, the constant busy-ness is overwhelming; players spamming buttons, pulling levers, spinning the wheel, gambling on the outcome of sports games, playing cards, feeding the machine, cashing out, breaking bills, ordering drinks or even buying a souvenir. A single player will easily generate a thousand transactions in one sitting. When you look at an online casino, this isn’t very different. In the system we inherited, the biggest and busiest aggregate by far is a user’s account. Basically every action that has money involved, leads to activity on this aggregate. This makes sense. An account is an important consistency boundary, if not the most important one. Casino’s can’t afford to have people spend more than their account’s worth. ...

November 9, 2014 · 4 min · Jef Claes

Programmatically force create a new LocalDB database

I have spent the last week working in an integration test suite that seemed to be taking ages to run its first test. I ran a profiler on the setup, and noticed a few things that were cheap to improve. The first one was how a new LocalDB database was being created. An empty database file was included into the project. When running the setup, this file would replace the existing test database. However, when there were open connections to the test database - SQL Server Management Studio for example - replacing it would fail. To avoid this, the SQL server process was being killed before copying the file, waiting for it to come back up. ...

October 26, 2014 · 2 min · Jef Claes