What I Learned Approching Idris With An Agenda

A few years ago I wrote up a little Scala library for dealing with dimensioned units of measure. This had two implementations. One was type-safe, but required defining all the combinations of dimensions and the operators to yield them manually. One was dynamic, determining the dimensions of a given quantity based on the dimensions of … More What I Learned Approching Idris With An Agenda

How To Find Bugs, Part 4: Design -> Analysis -> Design

At LMAX, we have a bit of a case of primitive obsession. Many datatypes are represented internally with longs: prices and quantities (in a fixed-point representation), contract sizes, and IDs for more or less everything (customers, instruments, all sorts of things). This is a deliberate tradeoff: while we understand the benefits of a richer set … More How To Find Bugs, Part 4: Design -> Analysis -> Design

How To Find Bugs, Part 3: @VisibleForTesting

Sometimes, doing things properly is hard. When that happens, there’s always @VisibleForTesting. To quote the Javadoc: @VisibleForTesting annotates a program element that exists, or is more widely visible than otherwise necessary, only for use in test code. There are occasions where @VisibleForTesting is the best solution, I suspect: I’m not entirely sure what they are. … More How To Find Bugs, Part 3: @VisibleForTesting

How To Find Bugs, Part 2: Well, this is somewhat confusing and frustrating

Last time we implemented a minimal detector, and I presented the code for the detector as a fait accompli. Let’s take a closer look at it.   import java.nio.file.Files; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.classfile.ClassDescriptor; import edu.umd.cs.findbugs.classfile.DescriptorFactory; import edu.umd.cs.findbugs.classfile.MethodDescriptor; public class FilesLinesDetector extends BytecodeScanningDetector { private static final ClassDescriptor JAVA_NIO_FILES = DescriptorFactory.createClassDescriptor(Files.class); final … More How To Find Bugs, Part 2: Well, this is somewhat confusing and frustrating

How To Find Bugs, Part 1: A Minimal Bug Detector

Findbugs is an incredibly powerful tool, and it supports running of custom detectors. However, the API for writing custom detectors is not well documented, at least as far as I’ve been able to find. So, as I started writing detectors, I’ve been working primarily off a process of trial and error. It’s likely there are … More How To Find Bugs, Part 1: A Minimal Bug Detector

Yet Another Python Multimethod Decorator, Part 6: But Wait, There’s More!

Somehow this ended up unposted and thus out-of-order, bah… So, we’ve now got a reasonably complete implementation of multi-methods for Python. I can feel some objections brewing in the minds of some readers – aspects of a “proper” multiple dispatch mechanism that I haven’t addressed here – but hush, there are some points I’ll arrive … More Yet Another Python Multimethod Decorator, Part 6: But Wait, There’s More!