Category: Code
-
Copypasta, you’re the worst pasta
Copypasta. It’s the worst. “I need something like this code here, I’ll just drop it over there where I need it. Maybe change a few things.” Only you can prevent headdesks! It’s not really possible, in my experience, to make it easier to use code through methods and functions than to just copy what you […]
-
Through mocks and back
A problem with double/stub/mock libraries is that they don’t often fail in a total manner. They don’t snap like a pencil when they’re used improperly. Instead, when you use them unwisely, they lay in waiting. At an inopportune time, they leap out. Change an internal API method name or argument list and your poorly conceived […]
-
Does an unadvertised extension point even exist?
There was an extension point, but I missed it. I was adding functionality to a class. I needed to add something that seemed a little different, but not too far afield, from what the existing code was doing. So I came up with a good name, wrote a method, and went about my day. A […]
-
The TTY demystified. Learn you an arcane computing history, terminals, shells, UNIX, and even more arcanery! Terminal emulators are about the most reliable, versatile tools in my not-so-modern computing toolkit. It’s nice to know a little more about how they work, besides “lots of magic ending in -TY”, e.g. teletypes, pseudo-terminals, session groups, etc.
-
Clinton Dreisbach: A favorite development tool: direnv. I’ve previously used direnv to manage per-project environment variables. It’s easy to set up and use for this. I highly recommend it! But, I’d never thought of using it to define per-project shell aliases as Clinton does. Smart!
-
Turns out Ruby is great for scripting!
Earlier last year, I gave myself two challenges: write automation scripts in Ruby (instead of giving up on writing them in shell) use system debugging tools (strace, lsof, gdb, etc.) more often to figure out why programs are behaving some way Of course, I was almost immediately stymied on the second one: dtruss is the […]
-
Tinkers are a quantity game, not a quality game
I spend too much time fretting about what to build my side projects and tinkers with. On the one hand, thatâs because side projects and tinkers are precisely for playing with things I normally wouldnât get a chance to use. On the other hand, itâs often dumb because the tinker isnât about learning a new […]
-
The least bad solution
Sometimes I look over the options and constraints to choose something suboptimal. I have to pick the least-bad solution. I recently chose a least-bad way to write a test. In a Rails app, the most sensible thing to solve my problem was something like this: In the test, I ended up having to write this […]
-
Wanted: state machines in the language
Our programming languages are often structured around the problem domain of compilers and the archaic (for most of us) task of converting things people understand to a thing the computer can execute. Why donât our languages have deeper support for the ways we reason about problem domains or the ways we struggle to reason. For […]
-
Weâre all adults here, but weâre not all mind readers
My favorite advice on the topic of method visibility (i.e. public vs. private) comes from Python creator Guido van Rossum. It goes something like âweâre all adults hereâ and says itâs not really a necessary thing for compilers/runtimes to hide methods from specific callers. Donât go mucking around in other objectâs implementations. I still think […]