Niko Heikkilä

September 5, 2021

Craftsman's Log – 2021.09.05

Oh, hi! How is your September going? I've been reading again. I'm drafting this post with the Day One app, which I migrated to from Notion. I also tried Emacs' Org Mode for bullet journaling, but simplicity always wins.

The Human Side of Elixir

I've been studying Elixir programming language and its tooling occasionally, but somehow I never got the chance to start working on a project with it. This article about the human side of Elixir should convince me — and possibly you — otherwise. It is, indeed, a language from which both seniors and juniors can benefit.

An important thing to take into account for both Elixir veterans and new comers is that the developer experience is seriously top notch. This directly impacts how quickly people can pick up both the language, and the ecosystem libraries. For example, HexDocs hosts all of the docs for all of the libraries published to Hex.pm which in turn gives you a consistent method for looking up documentation on all of you project dependencies.

From Post-Mortems to Pre-Mortems

Most of the time, while we transform processes to their improved versions, we should be ​shifting left​. It just happens that post-mortems done after an incident has wreaked havoc on our business can also be conducted as pre-mortems. Bundle this with chaos engineering, and you have a terrific way of building operational resilience for your team.

Pre-mortem is a strategy in which a team imagines that a project has failed, and then works backward to determine what potentially could lead to the failure of a project. The term was coined by cognitive researcher Gary Klein.

The Gateway Pattern

While developing backend systems, I've usually written transformer logic to simplify using a 3rd party API. But, unknowingly, I've been leveraging a design pattern called Gateway, a compelling pattern in creating a boundary between your system and the outside world. It helps with testing, too, as it provides an easy way to drop in a test double.

I use a gateway whenever I access some external software and there is any awkwardness in that external element. Rather than let the awkwardness spread through my code, I contain to a single place in the gateway.

The Seven Virtues of Well-Craft Code

We should talk more about the virtuous code. You know, that kind of code that works, isn't duplicated, is simple, clear to understand, easy to change, and expressed briefly. Have you seen anything like it?

The idea of code virtues is not to replace or augment any laws of software design, but to help recognise and describe the goodness we see in good code.

The Anti-Pattern of Reducing Arrays

This might be an unpopular opinion, but that only makes it a doubly more important topic to discuss. For a long time, I've considered some of JavaScript's array-based operations confusing — think especially about the juniors in your teams. Array.reduce() is a perfect example of functional code smell unless you're computing a sum of numbers in a list or other trivial operation. Problems arise when we use reducing when computing new objects, arrays, and other complex data structures instead of primitive values. Furthermore, when used with spread operator, there is also a performance penalty to pay. There's often nothing terrible about using regular for-loops. If your team has banned using those because code must be functional, consider raising your hand in a discussion.

One functional downside: hidden iteration. Seems some coders would balk at for;for;for; but have no qualms with .map.filter.reduce.

Becoming a Terminal Hero with Fish Shell

I've been thinking of writing about my Fish shell configuration, but someone always beats me to it. Yes, I get it, you might be using Oh My ZSH comfortably right now, but that's equal to drinking a perfectly adequate pint of 1664 Blanc before entering the world of more delicate wheat beers. Try going fishing next.

It’s not until you experience the intelligent auto-suggestions and completions in Fish, however, that you truly realise what you’ve been missing. And that’s before you learn just how easy it is to extend as nearly everything is a function.

…And Managing Your Terminal Like a Superhero with Tmux

Managing multiple workspaces was painful before I learned how to use a terminal multiplexer's window and pane management features, commonly known as Tmux. Currently, all it takes for me to get set up for writing code is to run tmux attach, and my persisted session comes alive with a dedicated window for each project split into two or more panes. So here's a gentle guide to nudge you forward.

Most of the folks praise tmux for its session management. Imagine sessions as different areas of work you do. For example, one session can relate to your private web project where you run frontend, backend, editor, tests, and so on. Another session can be an SSH session on some server where you are messing around with infrastructure.

About Niko Heikkilä

Hey there! I'm a Software Craftsman and Extreme Programmer. Currently, I do DevOps at Polar Squad. I build proprietary software for a living and loving it as much as free and open-source software. Follow this blog for insights on tech, culture, politics and all the small things.

For shorter ruminations, follow me on Mastodon and Bluesky.