The things you learn

There are no seven-page proofs in a 200-level class. Even when it’s Adelberg.

It was something like the spring of 1984, and I was (as usual) struggling in Professor Adelberg‘s class on Series and Differential Equations. And as usual, I took advantage of his office hours, on the second floor of ARH.

I don’t remember where the proof was supposed to end up, but I had about seven handwritten pages that sort of got me there. Not quite.

Professor Adelberg, sitting by my side at his desk, said, “Look, this is a 200-level class.” He paused slightly. “There are no seven-page proofs in a 200-level class.”

In this class, he said, you know you’re on the wrong track if your proof is more than about two pages. It’s a class full of people maybe a year and a half out of high school; we’re simply not at the level where theory gets that heavy.

Why am I telling you this?

I don’t remember very much in differential equations–I’ve always been more of a finite math and number theory kind of guy–but I remember that encounter because the lesson is always fresh. An answer that’s too hard is likely to be the wrong answer.

This morning, I had coffee with my homeboy Joe Fiorini, as a high-level pairing exercise. He was kind of busy, so we only hung out for about 45 minutes, which turned out to be an advantage. I’d been poking around at this JavaScript code for a day or so. All it had to do was maintain an array of user-selected IDs from a database table, show an HTML DIV of the IDs already selected along with descriptive data, open an HTML DIV to show a picklist of those not already taken, and let the user add the selection of another item, by choosing it from the picklist.

Its a “200-level class” sort of problem, isn’t it? But wow… I was cranking out that seven-page proof. Initializing the array. Refreshing the DIVs. Embedding links as A tags into the generated HTML. Making Ajax calls to repopulate the list in case it changed. I was getting a lot of mileage out of Firebug, which is never a good sign.

That’s about when Joe walked into the coffee joint.

I told Joe the story about Adelberg and the seven-page proof.

Joe said, “Let’s step back a minute. This is all in an HTML FORM, right? Why don’t you keep a hidden INPUT field containing the record ID in each LI? Then your array is right there. Not in the JavaScript.”

While I sat there flapping my face like a fish, because of course Joe was right, he went on: “And since this is a many-to-many relationship, you can set the NAME of that hidden field by convention to let Rails save it automatically to the join table.”

Which makes my Model logic drop-dead simple. It might even work by default. 130 lines of JavaScript will probably get cut down to a couple dozen.

Professor Adelberg, meet Joe Fiorini.

5 thoughts on “The things you learn”

  1. Great story Mark.
    I’ve been there too. It’s really easy to overthink things. I was working on a project for a client that looked like it was going to require a bunch of custom javascript, which was also going to cost more than the client wanted to spend. So I set the problem aside for a bit. Then suddenly the next day I realized I could accomplish what he needed with something as simple as an embeddable form from Mailchimp. I didn’t have to re-invent the wheel at all, I could simply adapt something that already existed and apply it to our situation. When you have a big toolbox it can be tempting to use every tool, but sometimes all you need is one small hammer.

    Sometimes we just need to look at the problem from a new angle. And often the easiest way to do that is to show it to someone like Joe (who has also given me good suggestions re: e-commerce) who can look at the situation with a fresh perspective.

  2. Thanks for the love. That was a great learning experience for me too! Although I’ve been doing it for months, I hadn’t put words around the “markup as in memory storage” concept. Of course, that could get of hand if this list was going to have hundreds to thousands of items in it.

  3. Hey Joe, here’s my crazy idea. What if I put the whole list into my UL and then just turn selections on and off with CSS classes? The classes can make unchosen items invisible, or dimmed, or whatever else works from a visual design point of view.

    How’s that for markup as in-memory storage?

  4. Leave it to you Mark to get me interested in something I normally have zero interest in.

    Personally I think complexity is the Devil’s playground.

    Thanks for making me think and smile.


Leave a Reply

Your email address will not be published. Required fields are marked *