Mar. 14th, 2012

elfs: (Default)
Can you tell us more about the technologies you used to create this web application [Fridgemagnets]? I'd love to hear about the process you went through as you envisioned the project, chose technologies, and figured out how you'd code it.

Well, let's start off with the basics. If you look down at the footer, you'll see this line: "inspired by twittermagents.com and an allergic reaction to all things flash." Now the fact is I love +GOOD and the design sensibilities they had, but something about twittermagents rubbed me wrong. It wasn't just the Flash, although that was certainly part of it. It was the way the user was forced to create a 'fridgemagnet poem by putting them into a constraining box. People don't have a constraining box for their poems on their refridgerator: they just arrange them wherever they can and hope other people can make sense of them. We recognize a 'fridgemagnet poem by recognizing a meaningful and deliberate arrangement of words.

I already had a (fairly) complete toolbox: I knew that if I wanted to reproduce this in HTML5, I would be writing with HTML, Javascript, CSS, and I would probably be using jQuery. To simulate the "scatter" effect I would need a way to do CSS transform, so I searched for a jQuery plug-in that provided them. I would need jQuery-UI for drag-and-drop. And finally, to get the music effect of the original, I would need an HTML5 equivalent: a little searching and I found Buzz.js.

I don't really code in HTML, CSS, and Javascript anymore: I use HAML, Less, and Coffeescript instead. I like these technologies because they eliminate one whole class of errors. (They can introduce bloat and inefficiency, though, but it's easier to optimize a solution than fix a problem.) So my next step was to create a working environment where those were installed, and then write a Makefile to make converting from these pre-processed languages to their results easier.

I started with the HTML, since that was easiest: I knew I had three regions, a "board", a control panel and a footer. The control panel would have only a few things (volume control for the music, the shuffle button when I get around to it, the tweet button too). The last two had fixed heights. The board would have a "results" section to show the poem as it was being rendered.

I assembled some CSS as I was doing this to give the fixed-height items their necessary space.

At this point, I got stuck: what was I really doing here? At first, I was just throwing stuff at it to see how close I could get. I had some lovely backgrounds, and had some music, but what the heck was I really doing?

I wrote out some notes: The board must be resized when the user changes the size or orientation of their display. Words fill the board on start or shuffle event. A word has a bounding box, which defines how it looks and a larger box... No, that wasn't right: The board is full of tiles which have words on them. When a word is moved, we have to determine if it's part of a poem or not. Italicized words became classes, and bolded ones became events. Some events have to be abstracted: "moved" became "dragged" and "dropped," and had visual side-effects: the "pick up" and "put down" routines.

Now, since every tile has (top, left, height, width), I could theoretically know when two tiles were intersecting. I searched for "How to tell if two boxes are intersecting, naive."

The word "naive" is the key there: if someone uses the word "naive" to explain an algorithm, it's because they're going to show why it's naive and explain how to implement the algorithm correctly. This is what led me to game programming and the Separate Axis Theory. I gave myself a crash course in vector mathematics and wrote an SAT library for javascript over the weekend.

Once that was done, it was a fairly simple matter of (1) creating an object to hold each word, (2) adding the words to the board in a "hidden" way, (3) unmasking some 60 or so of them [Math.random < (60 / no. of words)], and (4) animating them to "fly in." All of these were basic jQuery capabilities.

I knew I need them to be drag-droppable, so I read the drag/drop documentation and added that capability.

This was the real fun. I spent a lot of time thinking about the tiles and collisions, and trying different ways of making sense of the problem until I wrote out the basic algorithm. Then it was a matter of reasoning about the results: board, poem, and tile. Was the tile in a poem, or had it left a poem? If the poem split in half, what was the poem "now"? None of this had "side effects," so it was all about geometry and decision making: pure functional stuff. So I made up rules: "The poem determination routines all take a poem and a word, and return a new poem." The new poem might be an exact copy of the original, if all you did was move a word slightly, but as long as my functions did exactly that, I knew they weren't going to break anything else.

After that, it was a matter of rendering the side effect: drawing the "found poem" in the lower left corner.

I had never worked with game algorithms like this, but they were only a short stretch from the clock algorithms I'd used for Arc Experiments. Abandoning my beloved Backbone for a home-made solution was a matter of understanding that I had only one data structure and would save a ton of unneeded code managing it myself. The music API was "just" an API: anyone could use it after reading the documentation.

The biggest insight was the creation of the Dimensioned prototype, which allowed me to use a "write-only DOM" method. I'd learned about that by following the Javascript Zeitgeist on Delicious. I haven't quite hit it-- as I said, this is a rough draft, but it expresses some essence of the final draft, and I wanted others to see where it was so far. But by using it, I was able to write simple code that said things like "Tell me if these two objects are intersecting," which then made scanning for intersections, and groups of intersections, fairly trivial.

In many ways, programming is more craftsmanship than engineering: we know what tools we have, and we know what things we'd like to do. Sometimes I stretch my skillset out in one direction, and that's what Fridge Magnets does. Reading through the code, you can see little bits that are commented out still: during the "fly in," words aren't supposed to land on top of each other, but they do, because the check just says "they're not colliding," even when they are. It turns out that was okay, visually-- but now I have to say something like "When a user picks up a word, bring its stack order up one so it's 'above' everything else." That may be more visually jarring than sliding it out from under a covering word-- I'll have to see.
elfs: (Default)
Looking through a raft of timers, clocks, stopwatches and the like for the Android, I've come to realize that many of the great Human Interface Design lessons of the early 90s, of the original Blackberries and Palms, have been sacrificed to the "ooh, shiny!" of AMOLED screens and better CPUs. The Android "anything goes" guidelines have resulted in tragedy.

For example: it takes THREE gestures to get to the "last app" on your Android. It takes FIVE to get to the Home page. It takes six to get to a "frequently used application," seven to to nine for less frequently used applications.

Contrast that with the Palm: ONE gesture to the last app, ONE gesture to the home, ONE gesture to your top three applications, TWO to FOUR gestures for all other applications.

Another example: the typical timer application on the Android has a "tap-and-hold" method for setting a countdown. If you're trying to get to 45 seconds, you tap-and-hold the "up" button, a very non-tactile experience-under-glass in which you have to guesstimate when you're "close" to 45, then stop and tap to your target one second at a time, all the while your big hand may well be obscuring the input.

Contrast this with two different timers for the Palm. Big Clock had an individual tap for seconds and tens of seconds. 45 seconds is nine taps above the number, with big haptic regions of affordance and an easy count in your head-- no guessing there at all, and you can't make a mistake even if your hand is in the way. Pocket Doan, my meditation timer, was pure minutes-- in an in-page drop down! Tap for drop down, tap for 15 minutes. Or 20, or 25. If you needed something weird, like "17" minutes, the bottom of the menu was "Custom," which not only went to a pop-up for big haptic taps like Big Clock, but let you use the keyboard to input the time as well.

Hands do things. They hold, manipulate, touch, grasp, grab, push, shove. The Palm Pilot understood this, making initial contact tactile and fast, emphasizing reading over input, and making input absolutely simple when necessary.

Android phones with motion sensors can now tell when you're holding one up to your face. The SOAP project was an experiment in having the device automatically start some apps after certain motions, like the camera if you held it like a camera. More of that needs to be done.

But more than that, manufacturers need to not be afraid to put physical buttons on the outside of the phone. Why is "volume" privileged with external buttons, but "calendar," "note pad," "ebooks," and "productivity timer" not? It would be easy to set the buttons to all be "power" to begin with, and then let users discover, using a standard gamification & DITA algorithm, that they could program those buttons to go straight to their favorite apps.

Anyway, I'd like to see programs like Big Clock and Pocket Doan on the Android. I hate the Eclipse integrated development environment, have never seen the Android API, and haven't programmed in Java in 14 years. I understand a lot has changed.

This shouldn't take long.
elfs: (Default)
I rarely regret not spending money. When I went to finally upgrade my phone, I blanched at the MSRP of an unlocked Galaxy Nexus GSM, which at $659 was a lot of cash. Especially since my provider, AT&T, was basically offering me the Galaxy SII (not the "Note" or "S+", mind you) for basically nothing more than a promise to stay with them for another two years.

Since I needed a network provider anyway, I went with the Galaxy SII. I am now regretting that decision. This is a terrible, terrible phone.

Battery life is less than 11 hours with no use. If you have a regular work schedule with some commute, and maybe get some texts and emails and phone calls through the day, this phone is likely to die before you get home. There are services you can "disable," such as Tethering, Wi-Fi Hotspotting, and AT&T "Navigation Help" services, but the processes never shut down. The phone always restarts them. I have no idea what interrupts they're banging on inside the OS, but it's probably eating the battery alive along with everything else.

I even took it back to the AT&T store and complained about it. I said the phone's behavior isn't matching the claimed specifications or the popular reviews, that the phone would last for at least a full day with "typical" use. With no use this phone doesn't last through the regular workday, much less the evening. This is not acceptable. When I started to get loud enough that other customers were becoming uncomfortable, the saleshole told me, "You'll just have to get used to recharging it twice a day. I'm sorry, that's what Android phones are like."

Bleah.

Some people have said that new phones take a while to calibrate their batteries. I have my doubts.

I also looked at a lot of timers to replace Pocket Doan, the beautiful meditation timer for the Palm. Nothing like it exists for Android. I used it for meditation, but also as a productivity app, since it has a lovely pomodoro setting. The first time I used it, it worked fine until the end, at which point it said: "Congratulations on meditating for 25 minutes. 70 other people are meditating right now." I didn't want to know that; I also didn't want to share my own meditation (or whatever) sessions. Genuinely creeped out, I deleted the app when I realized I couldn't turn that "feature" off.

Bleah twice.

I'm annoyed because I let a financial consideration that, really, was not all that big a deal, compromise my sense of ownership of an electronic device. I owned my Palm Pilot and my iPod. I pwned my last phone, and my Nook. I do not own this phone.

And that means It is leasing Me.

Sigh.

Profile

elfs: (Default)
Elf Sternberg

December 2025

S M T W T F S
 12345 6
78910111213
14151617181920
21222324252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 4th, 2026 08:47 pm
Powered by Dreamwidth Studios