Fri 08 Jul 2022

Why DRY is the most over-rated programming principle

I suspect any developer reading this is aware of the DRY principle because it is just so ubiquitous. If not though, you just need to know that it stands for "Don't Repeat Yourself" and is generally invoked when advising people to not copy and paste snippets of code all over the place and instead consolidate logic into a central place.

DRY was the first programming principle I encountered and probably the only one I was aware of for the first year that I was a developer. It's also probably one of the simplest principles to understand. If you see two things in your code that are the same, maybe they should just be one thing. Hard to argue with that. But, I think that DRY is just like every other principle out there - it has its place, but it's best taken in moderation. And I think that, due to its ubiquity and simplicity, we tend to take DRY too far, far too often.

Source: Why DRY is the most over-rated programming principle, an article by Gordon Cassie.

Painlessly developing Python on NixOS with pipenv

For a long time, I’ve wanted to develop Python code on NixOS, but using Nix to manage dependencies was a major pain. If the dependencies you want are already in Nixpkgs, then you’re good, but otherwise you need to use things like pypi2nix to turn Pypi packages into nix derivations. This never quite worked out for me, so I ended up writing the nix derivations myself… which sucked.

I’ve been aware of pipenv for a while now, and it seemed like the ideal solution. It gives Nix/Stack/Yarn-like reproducibility, while still being actively maintained, unlike some of these Nix-specific Python package tools. I had never managed to get this to work for me, but I’ve finally got a configuration working on Nix.

Source: Painlessly developing Python on NixOS with pipenv, an article by Sidharth Kapur.

How to Achieve Dynamic Dispatch Using Generic Protocols

As easy as it seems to achieve dynamic dispatch in OOP, it is not the case when it comes to Protocol-Oriented Programming (POP). Trying to accomplish dynamic dispatch using protocols always comes with unpredicted difficulties due to various limitations in the Swift compiler.

With the release of Swift 5.7, all these have become history! Achieving dynamic dispatch in the realm of POP has never been easier. In this article, let’s explore what kind of improvements we get from Swift 5.7 and what it takes to accomplish dynamic dispatch using protocol with associated types.

Source: How to Achieve Dynamic Dispatch Using Generic Protocols in Swift 5.7, an article by Lee Kah Seng.

Encanto (2021)

A Colombian teenage girl has to face the frustration of being the only member of her family without magical powers.

In the evening Adam, Esme, and I watched Encanto. I liked the movie a lot; beautifully made, and give it an 8 out of 10.