Skip to content

Instantly share code, notes, and snippets.

@ojplg
ojplg / why_i_write_tests.md
Last active December 15, 2020 13:50
testing thoughts

I think there are seven reasons why writing tests during software development is a good practice for me. Here they are. (There is some overlap in the reasons, and some might agree with all the points, but still find a different classification made better sense.)

  1. Correctness. Writing tests means that the code that I write is more correct. There are fewer errors, bugs, or unwanted behaviors. I think this is fairly universally accepted, so I will not belabor the point.
  2. Shortened feedback loop. Writing tests creates a much improved feedback loop compared to running an application and inspecting its outputs. Writing a test is almost like being in a REPL, except I am in an editor and so everything I do can easily be saved. (I know more advanced programmers know how to run REPLs within their editors. Wizards.) I think that Jane Street's Jenga/Emacs integration is particularly shiny and sweet in this regard.
  3. It's a free client. Suppose I'm writing a module to provide frobulation. It's likely that I have onl
@ojplg
ojplg / StreamSelector.java
Created April 15, 2019 23:11
HrormStreamSelector
package org.hrorm;
import java.util.Spliterators;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
public class StreamSelector<ENTITY> {
#!/usr/bin/perl
use strict;
use warnings;
# imgpg -- create an index page with thumbnails for some images in a directory
# open files in directory
# use image magick to create thumbnails
# write a quick index.html which includes thumbnails and links to each image