1. 6
  1.  

  2. 5

    Vector go in, pairs come out. None of all of that other stuff matters. You could call this “premature de-optimization”, because the other answers were more wordy, but the other answers were making the same mistake the imperative guys were: mixing up analysis and code without realizing it.

    I tend to like the term “functional decomposition” for this, but it’s very overloaded. I wish there was a term to grasp for taking the problem and rotating it so that as much as its complexity as possible points into the “generic tooling dimension.” In other words, we find that instead of decomposing the problem along the business axis, we can rotate it into the tooling axis and then we can pull out complexity through a pure, colorless tool like zip, leaving the business domain less complex “for free”.

    I notice this a lot in our domain code at work. (D is a surprisingly functional language.) When I’m trying to operate on some data, often the first thing I do is define some one-liner helpers so I have the generic verbs to even talk about the transformation I want to do. Preferably, these should just describe changes in the shape of the dataset, without commenting on the actual meaning of the data. So you can understand them on their own, maybe with some example integers for a unittest, before you go on to apply them to the actual problem.

    1. 2

      Well, it’s Saturday morning and I’m feeling particularly philosophical. To riff on your idea about the axes, you got me thinking about Principal Component Analysis and a sort of qualitative version of it: how well do the “pieces” of a codebase align with either the business axis or the tooling axis? I’ve worked on codebases where the first two unit vectors of “PCA” of the “pieces” of a codebase would align very well with the business & tooling axes, and other codebases where they wouldn’t. The ones with good alignment were definitely way better to work with!

      1. 2

        I tend to like the term “functional decomposition” for this

        This is usually how it’s taught: as a way to “clean up” the code. The problem is that we want to hold the code at arm’s length, apply some mechanical cleanup processes to it. You end up solving the immediate problem at the expense of the larger system.

      2. 2

        I love this coding style. In Lisp:

        (zip lis (cdr lis))

        1. 3

          In D: alias pairwise = range => range.zip(range.drop(1));

          1. 2

            Also, I commented on the blog but while it’s in moderation: Rather (and Montgomery), not Lennon.