Category Archives: Programming

How do people manage JavaScripts projects that contain multiple NPM packages?

With my Index Data colleagues, I am working on “Stripes”, a UI toolkit for the in-progress library services platform FOLIO. Because it runs in the browser, the Stripes code pretty much has to be JavaScript, and because it’s a non-trivial bit of work, it brings in multiple modules from elsewhere — something that is traditionally done using NPM, the Node Package Manager, which is what we too are using.

nigiri-maki-selection-yo-sushi

But Stripes is made up of several NPM packages: stripes-core, stripes-connect, and so on. And they use each other. In particular (let’s make things simple by picking a single example), stripes-core uses stripes-connect.

Continue reading

The worst decision in the design of the Internet

The Internet is a frankly incredible design. The IP protocol, which is at its heart, is technology from 1974. TCP, which implements connections on top of IP’s packet delivery, is from the same year. Forty-two years on, both are essentially unchanged. Even DNS, the domain-name service, dates back to 1983, and is going strong 33 years in with only minor tweaks.

The only big change in this time has been the slooow migration (still in its early stages really) from IPv4 to IPv6 — something that has proven necessary as the Internet has been so wildly more successful and popular than anyone anticipated, and the 32-bit-wide host addresses are running out. But in the scheme of things, this is a minor tweak. We’re running the Internet on 1970s technology, not due to sloth, but because it’s good.

sushi-2

Continue reading

A coding confession

I just found this code in one of my source files:

for (HashMap.Entry<String, Void> e2: map.entrySet()) {
  if (eventName.equals(e2.getKey())) {
    m.handle(eventName, data);
  }
}

Yes. I was iterating through the keys in a HashMap to find out whether the one I wanted was there. But the whole point of a HashMap is that looking up a key is an O(1) operation.

What I should have written is:

if (map.containsKey(eventName)) {
  m.handle(eventName, data);
}

The moral of the story: I can be really, really dumb. (But hey, at least my code worked!)

Dependency injection demystified

At the moment, most of my actual coding work is in Java — which is a novelty for me, as it’s not a language that I am naturally inclined to like. But as I’m coming to grips with it, I’m finding that Java in 2015 is a rather more pleasant language than the one I wrote a CQL parser in back in 2002. The main problem with it is the culture, and in particular the huge vocabulary of patterns, which takes a long time to learn.

20120220_2

So here is today’s brief lesson, which is on dependency injection. Continue reading

New free software for drawing diagrams of vertebral columns

I already blogged about this over on Sauropod Vertebra Picture of the Week, but since it’s a software release, I figure I ought to mention it on my programming blog, too!

wedel-and-taylor-2013-bifurcation-figure-9-bifurcatogram

Matt Wedel’s and my 2013 paper on bifurcation in the neural spines of sauropods included the figure above, which shows in schematic form what we know about split spines in the vertebral columns of various specimens. Rather than draw this by hand, I wrote a program to generate it from a simple textual description. Continue reading

JavaScript hashes that inherit from a parent

For a JavaScript program I’m working on, I want to have hashes that can inherit values from a parent. Specifically, I have many widgets, each with a (usually small) hash of configuration parameters; when I access such a parameter and it’s not defined in the widget I want to get the value from the configuration of the team that the widget belongs to; and when that’s not defined I want it to get the value from the global configuration.

sushi-by-rob-owen-wahl-small

Continue reading

… Or maybe they’re doing web-site registration completely right

A couple of weeks ago, I wrote that DeviantArt are getting web-site registration completely wrong by asking for the email address (which you can see as you type it) to be repeated, but not requiring confirmation of the password (which you can’t see).

deviantart-registration-small

A lot of people in the comments (both here and at Hacker News) pointed out that I was wrong.

Continue reading