I’m job hunting and today I had the pleasure of talking to Cable. They want to tackle financial crime and improve our currently abysmal efforts to reduce financial crime (currently only a tiny percentage of financial crime is caught).

In preperation I watched this talk by Natasha the founder, which really got me thinking about the nature of crime. Natasha’s point is that most crime is financial crime, in that lots of crime involves a financial gain. That means if you can tackle financial crime in some way you make a good dent in all crime.

Why does crime happen?

Laws and law enforcement are deterents to commiting crime because they offer a cost to commiting it. They do that by saying “if you commit this crime and get caught you will go to jail for X years”. For that deterrent to work certain things have to hold true. …


Image for post
Image for post
Photo by Edu Lauton on Unsplash

I wanted to show the way I’ve been thinking about structuring umbrella apps in Elixir applications. I’ve been using this approach for a while and have found it useful. I have also made a template repo in github to get you started if you want to try it out when building a graphql API in elixir.

I like umbrella apps because they are a nice way to declare and separate internal dependancies. They enforce a one way relationship between apps; one app includes the other, and that’s that. …


Image for post
Image for post
Photo by Shaojie on Unsplash

What exactly is immutability? What are the implications of immutable data types in our languages?

What is it?

Immutability is a constraint on our data types that says “this data type cannot be modified”. On the surface this sounds like very counter intuitive thing to want. How on earth can we do anything if we can’t change any data?!

Well, we do it by making a copy. Here are two examples in javascript the first uses a mutable data structure, the second is how we would have to do it if the data type was immutable in javascript

let mySandwich = { bread: "brown", butter: false}// This is a mutable update
function mutableButterSandwich(sandwich) {
return sandwich["butter"] = true…


Image for post
Image for post
Pictured: disappointment. Photo by Sarah Kilian on Unsplash

Let me tell you about the time I accidentally deleted the users table. Why? Well people make mistakes all the time andI think it’s important to be open about them so they get fixed quickly. I think it’s important to normalize talking about mistakes because they are a part of learning, we all make them, and they are hilarious. So gather round….

We, like most businesses, have a users table. It has, as you may have guessed, data for all of the users of Nested. At the time of deletion the table was moderately large - not huge but several thousand rows, each with varying amounts of information depending on how far through the funnel a user got with Nested. …


Image for post
Image for post
Photo by Tomas Sobek on Unsplash

Protocols are a very powerful feature of Elixir. I’ve introduced them before here, and I looked at how you might use them to solve the expression problem here.

Today I want extend an idea I touched on in that last article and explain it better. It doesn’t matter if you haven’t read the previous article, but for context at the end of it I tried to show an example of triple dispatch. The idea was that you could decide which specific function gets executed according to the types of three arguments passed to a function. Usually we use single dispatch — we pass an argument into a function and because that argument is a string (say), it does one thing, if it were a different type, then it would do another. This is the essence of polymorphism — a single interface, but varying implementations depending on the type of one thing. But what would it look like if we needed the specific implementation of a function we wanted to run to be determined by the types of three things? Is there ever even a case where that may be useful? …


Creating a has_one_of association in Ecto with EctoMorph

Image for post
Image for post
Photo by Jason Leung on Unsplash

So what do I mean by has_one_of? Well sometimes when modelling data we want to say something like “this thing can be one of these types of things”. That is to say, our thing can be one of a group of possibilities, and can only be one of those at any one time. Why is this a useful way to talk about data? Isn’t that just a has_one anyway? Let’s look at an example to see…

We want to track athletes and their results in different events. To begin with we decide to have athletes, who have_one medal. …


Image for post
Image for post
Photo by Brooke Lark on Unsplash

In our previous post we took a little look at the differences between some common changeset functions in Ecto. Here I want to look a little bit more deeply into the cast functions cast_embed and cast_assoc. I want to show you how it is implemented (conceptually at least) and then present a library which provides some sugar over Ecto’s great work to help make turning raw data into validated structs a breeze. If you are not familiar with cast_embed and cast_assoc I highly recommend you read this post first

TL;DR the library is called EctoMorph and is availalble on Hex and github. You can jump straight to the docs there, but I hope you stick around here first. …


Currying. Another in a long list of words that anyone outside of programming hears and just assumes you are making up. Currying is a way to partially apply a function. What the hell does that mean? It turns a function that takes two arguments into a function that takes one argument and returns a function which takes the other argument.

Wut.

Observe...

In javascript, instead of having this:

let add = function(x, y) {
return x + y
}

we could do this:

let add = function(x){
return function(y){
return x + y
}
}

We could then call it like…


Image for post
Image for post
knowledge DOES grow on trees

This is part 2 of a three part series. Part one here, Part three coming soon.

Let’s start with a definition. When I say coaching, I mean the efficient transfer of knowledge from someone with more of it, to someone with less of it. In this article when I talk about coaching, I’m imagining you (the coach) as the person with more of the knowledge.

Coaching is a skill that will always be useful to anyone in programming. If you are senior, you will need to coach. If you are junior you will need to coach. …

Adz

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store