A friend, Jeremy Penner of Glorious Trainwrecks semi-fame, pointed me to this video:
Bret Victor - Inventing on Principle from CUSEC on Vimeo.
That's some amazing UI thought right there. I love how laying out animations can me more like puppeteering if you do it right... and the rest is completely inspiring as well.
Random plug: to get the embeded code the size I wanted it I used my old Youtube Resizer -- it needs a better name, since A. it works on things other than youtube (like Vimeo here) and B. Youtube has put the same functionality into their basic "embed this" webpage, but still, the thing works pretty well.
Monday, March 26, 2012
Thursday, March 22, 2012
wmode and putting flash in its place
Just a note for my future self: that whole "flash appearing in front of other content on the page thing" fix (otherwise flash weirdly, stupidly, appears in front of other content on the page, z-index wise) is setting wmode to opaque:
<param name="wmode" value="opaque"/>
One reference for that at stackoverflow. I've dealt with this before, right now I'm most annoyed at how Confluence's pdf viewer app doesn't do that and it would be some jar-ish hacking to get it to work so that the PDF viewer didn't block the zoomed in images. Bleh!
<param name="wmode" value="opaque"/>
One reference for that at stackoverflow. I've dealt with this before, right now I'm most annoyed at how Confluence's pdf viewer app doesn't do that and it would be some jar-ish hacking to get it to work so that the PDF viewer didn't block the zoomed in images. Bleh!
Monday, March 19, 2012
a more interesting news ticker
So it's been a little while since I've done a live demo here.
The other week on some website or other -- it might have a Sky-affiliated site? -- I saw a little news ticker that caught my attention. I created a simple mockup of its main action here-- go ahead and hit "ticker it"...
Now I've seen plenty of newstickers, even scrolling ones, but this was a little different: rather than being a simple thing that always scrolls, it starts at the left and builds to the right, only scrolling enough to keep the right edge visible, and the stopping the scroll. It ain't rocket science, but I find it a more natural way of reading than a traditional ticker... the user gets less impatient as the text builds in a more "normal" fashion, but still the animation makes it more engaging than a simple static headline (even one in those garish colors-- I believe yellow and black combo is thought to be the highest and most attention grabbing possible.) The construction invites the user to just keep looking, and builds a bit of suspense with what word comes next.
The other week on some website or other -- it might have a Sky-affiliated site? -- I saw a little news ticker that caught my attention. I created a simple mockup of its main action here-- go ahead and hit "ticker it"...
You can see my rendition of this on a standalone page, and view the source thereof, but there isn't that much to it, just some simple nested divs with hidden overflow and then some setTimeout javascript to adjust the relative positioning when jQuery's "width()" function indicates things are too long.
Thursday, March 15, 2012
many endpoints, one function: it all depends on what this meaning of "this" is
So as a follow up to today's post, I made a new feature for our site: the MultiDataGrabber.
There are two ugly Patterns I've seen when you need to build a page but there's an ordering dependency that requires information from 2 or more endpoints to be acted on: personally I'm guilty of making long, ugly function chains, storing data as we go, and then the final link in the chain does all the work. The other anti-pattern is to have a single function with 2 synchronous function, so the data can be returned. That's easy to read but causes the site to stall as the synchronous call completes.
I suggested a third ugly pattern: call the 2 endpoints asynchronously, and have each callback store its data in the parent object and check if the other callback has done likewise; if not, return, if so, call the function that uses the data. But at work Ben suggested this could be generalized: it would be nice if we could specify multiple AJAX URLs and then have a function that is called when they have all completed.
Thus, the MultiDataGrabber was born. It's called like this:
var mdg = new MultiDataGrabber(["/rest/user/location",
"/rest/ecommerce/account",
"/rest/user/style"], allDone);
function allDone(ress){
ccdebug("res 0:"+inspect(ress[0]));
ccdebug("res 1:"+inspect(ress[1]));
ccdebug("res 2:"+inspect(ress[2]));
}
There are two ugly Patterns I've seen when you need to build a page but there's an ordering dependency that requires information from 2 or more endpoints to be acted on: personally I'm guilty of making long, ugly function chains, storing data as we go, and then the final link in the chain does all the work. The other anti-pattern is to have a single function with 2 synchronous function, so the data can be returned. That's easy to read but causes the site to stall as the synchronous call completes.
I suggested a third ugly pattern: call the 2 endpoints asynchronously, and have each callback store its data in the parent object and check if the other callback has done likewise; if not, return, if so, call the function that uses the data. But at work Ben suggested this could be generalized: it would be nice if we could specify multiple AJAX URLs and then have a function that is called when they have all completed.
Thus, the MultiDataGrabber was born. It's called like this:
var mdg = new MultiDataGrabber(["/rest/user/location",
"/rest/ecommerce/account",
"/rest/user/style"], allDone);
function allDone(ress){
ccdebug("res 0:"+inspect(ress[0]));
ccdebug("res 1:"+inspect(ress[1]));
ccdebug("res 2:"+inspect(ress[2]));
}
Pretty easy, huh? Ben also mentioned if you were having to do too much of this (rather than, say, be able to build a page in parallel) it might mean you had a mismatch between what the endpoints were returning and the function of the page, so you might ask for a refactoring of the former.
The implementation is short, and has a point I want to discuss, so here it is:
function MultiDataGrabber(urls,callback) {
this._countNeeded = urls.length;
this._countHave = 0;
this._finalCallback = callback;
this.ress = [];
//go through each url, make a helper object to store the context
for(var i = 0; i < this._countNeeded; i++){
var url = urls[i];
var helper = new MultiDataGrabber_helper(i,url,this);
global_databroker.getJson(url,CreateDelegate(helper,function(res){
this.funk(res);
/*weird(this)*/
}));
helper = undefined;
}
this._myCallback = function(spot, res){
this.ress[spot] = res;
this._countHave++;
if(this._countHave >= this._countNeeded){
this._finalCallback(this.ress);
}
}
}
function MultiDataGrabber_helper(pid,purl,pmdg){
this.id = pid;
this.url = purl;
this.mdg = pmdg;
this.funk = function(res){
this.mdg._myCallback(this.id,res);
}
}
/*
function weird(what){
ccdebug(what);
ccdebug(this);
}
*/
So this code looks pretty obvious... as I read through it I think "aha, OF COURSE I have to make a helper object to store the state during the callback, and OF COURSE it needs a CreateDelegate so the scope doesn't get stomped" but when I was writing it I ran into enough dead ends that (as I've admitted before) I had to acknowledge I am not 100% fluent in Javascript Scoping rules. And I left a fossil of that with the commented-out "weird" function. The function is passed a variable "what", and prints out that, and then it prints out "this". When the code is run, it first prints the MultiDataGrabber_helper (since it has the CreateDelegate saying that that is the scope), and then prints the window object. But that seems odd to my Java-addled brain, because at invocation the weird() function was passed "this"... but it was a different "this" then you get when you're in the function itself.
Sometimes it alarms me that you can do so much in JavaScript without having this stuff down cold. If I had the same klutziness with Java classes, I'd never get anything done! (On the other hand, I had a cold bath awakening to Java's anonymous function callbacks when I had to use the "Wicket" framework. Apparently they are very familiar to people who used AWT and Swing and what not back in the day, and now I'm very comfortable with them, but then they seemed really ugly and strange.)
UPDATE: I made a Google Docs Presentation for a Boston jQuery meetup's 5 minute talk on this.
UPDATE TO THE UPDATE: At the meetup, Ben "Cowboy" Alman pointed out that functionality along these same lines was added to jQuery 1.5: they're called "deferreds", and defer (ha) to Eric Hynds' explanation of them. To be fair, I'm not sure if it would be easy to utilize them with the plumbing my company uses for AJAX (i.e. the databroker caching and the way we listen in to the traffic to know if we should stop polling for notifications) so I don't feel too too bad, but still it's nice to add this knowledge to my repertoire.
UPDATE: I made a Google Docs Presentation for a Boston jQuery meetup's 5 minute talk on this.
UPDATE TO THE UPDATE: At the meetup, Ben "Cowboy" Alman pointed out that functionality along these same lines was added to jQuery 1.5: they're called "deferreds", and defer (ha) to Eric Hynds' explanation of them. To be fair, I'm not sure if it would be easy to utilize them with the plumbing my company uses for AJAX (i.e. the databroker caching and the way we listen in to the traffic to know if we should stop polling for notifications) so I don't feel too too bad, but still it's nice to add this knowledge to my repertoire.
break the data: pump_databroker
Today I'm going to show a simple model for caching endpoint data (with an optional pubsub system for later in-page updates), a "databroker", so that a single page doesn't have to make multiple calls to the same endpoint.
At work, we were already doing a good job of using wrapper functions for jQuery's ajax calls, jsonGet and jsonGetSynch (for that nasty synchronous stuff). The main thing these functions did, besides simplifying the syntax, was enable a "keep alive" function, so that we could keep polling for notifications, but then stop polling after a given interval (so that the user's session wouldn't live forever as long as they had the page open). So one design criteria was that the databroker
So what does our databroker do? It stores the responses from ajax calls in an hashmap, keyed by the endpoint URL. (Furthermore, it automatically adds a timestamp to the requests to avoid caching issues) If a request for a URL comes in and the databroker has a cached response, the response is returned immediately, rather than making another call. Furthermore, if a pile of requests to a (possibly slow/long-running) URL come in at once, only one actual call is made, and then all the callbacks get called, passed the same cached data.
Furthermore, there's an optional "pubsub" publish/subscribe model. A request can specify a channel/tag it wants to "subscribe" to, and then when other operations update related data they can call "refresh" on that tag, and the subscribed callbacks are called with fresh data from the server
The implementation is here. It creates a global variable global_databroker. The syntax for the call is global_databroker.getJson(url, callback, errcallback ,tag]. Errcallback and tag are optional. There's also a getJsonSynch for synchronous calls, and that refresh() call. (I think the behavior might be a bit off for the errcallback relative to the pubsub system)
Because I am a bad person I did not write unit tests. I did write a test script, but since I haven't yet instrumented the calls, it relies on using firebug or the like to see when calls are made, and "ccdebug" in it prints to the console.
<script>
$(document).ready(
function(){
global_databroker.getJson("/rest/user/profile",function(res){
ccdebug("call profile 0 sub");
},ccdebug(),"sub");
global_databroker.getJson("/rest/ecommerce/account",function(res){
ccdebug("call ecommerce 1 sub");
},undefined,"sub");
global_databroker.getJson("/rest/ecommerce/account",function(res){
ccdebug("call ecommerce 2 nosub");
});
}
);
function FORE(){
global_databroker.getJson("/rest/ecommerce/account",function(res){ ccdebug("call ecommerce 3 sub");},undefined,"sub");
}
</script>
<input type="button" value="refresh sub" onClick="global_databroker.refresh('sub')">
<input type="button" value="do ecommerce 3 with sub" onClick='FORE();'>
In the page I embedded these comments:
<pre>
So in firebug, you should see:
in "ready" 3 requests, with 2 to ecommerce account queued as one
0 and 1 subscribe w/ keyword "sub", so clicking "refresh sub"
calls the calls to be repeated, and 0 and 1 get called back
click "do ecommerce 3 with sub" -- you see it immediately gets the info
without another call to the server
then if you hit refresh sub, 0 1 and 3 all get called back
</pre>
That's that! I think it works pretty well, and the implementation is reasonably compact.
(In the scheme I cribbed this from, the developer thought it would be good to automagically use the rest URL as the tag. (i.e. maybe just have a simple getJsonSubscribe() call). This would be especially cool if there was a 1:1 mapping between GET and POST URLs-- then anything you saw POST information could call any subscriber! In practice, though there isn't that 1:1 map. Not only that, there's often a disconnect where a POST Url ends up changing data retrieved by a totally different GET. That's why I like a generic tag system to decouple the input and the output to the server.)
Comments welcome.
(In the scheme I cribbed this from, the developer thought it would be good to automagically use the rest URL as the tag. (i.e. maybe just have a simple getJsonSubscribe() call). This would be especially cool if there was a 1:1 mapping between GET and POST URLs-- then anything you saw POST information could call any subscriber! In practice, though there isn't that 1:1 map. Not only that, there's often a disconnect where a POST Url ends up changing data retrieved by a totally different GET. That's why I like a generic tag system to decouple the input and the output to the server.)
Comments welcome.
Wednesday, March 7, 2012
the pirate kart
I do have a real post pending (need to figure something out with jsfiddle) but meanwhile I'd like to talk about the 2012-in-one Glorious Developers Konference Kollection Pirate Kart. It has its ultimate origin on a place called Glorious Trainwrecks, a site launched to praise terrible 90s homebrew shareware but now dedicated to the proposition that every can make games, and should.
The Pirate Kart of course shares that sensibility. The most recent Kart had been assembled for the Indie Games Festival Main Competition. Then there was a bit of a... political? motivation? It was meant as a playful argument against the "scenesterism" that sometimes haunts "Indie Games" as a movement.
The Glorious Trainwrecks has always had a spirit of openness, though originally there was an emphasis on use of a particularly peculiar no-programming game construction kit called "Klik and Play" (which is why Ks show up a lot on the site and its offshoots, a trend that as a guy named Kirk I kan only applaud) which let people whip together a game in the 2-hour Klik of the Month Klub events.
Personally, I tend to program in Processing (sometimes making Processing.js variants) which has the added benefit of keeping my Java skills from completely rusting. But more than that, making silly, 2-hour-game prototypes has given me a deeper sense of easy-to-code-but-juicy physics that really helps me make more intriguing and attractive UIs.
Anyway, here are my 5 games! Click to play them online and get some more details about the background story.
Of all of these, "action figure fighter" is probably my favorite, "robotish" is the best from a game-playing standpoint, and "dinobeeboxer" is just weird and cool.
The Pirate Kart of course shares that sensibility. The most recent Kart had been assembled for the Indie Games Festival Main Competition. Then there was a bit of a... political? motivation? It was meant as a playful argument against the "scenesterism" that sometimes haunts "Indie Games" as a movement.
The Glorious Trainwrecks has always had a spirit of openness, though originally there was an emphasis on use of a particularly peculiar no-programming game construction kit called "Klik and Play" (which is why Ks show up a lot on the site and its offshoots, a trend that as a guy named Kirk I kan only applaud) which let people whip together a game in the 2-hour Klik of the Month Klub events.
Personally, I tend to program in Processing (sometimes making Processing.js variants) which has the added benefit of keeping my Java skills from completely rusting. But more than that, making silly, 2-hour-game prototypes has given me a deeper sense of easy-to-code-but-juicy physics that really helps me make more intriguing and attractive UIs.
Anyway, here are my 5 games! Click to play them online and get some more details about the background story.
![]() |
| shave face race |
![]() |
| robotish |
![]() |
| dinobeeboxer |
![]() |
| hit or missile |
![]() |
| action figure fighter |
Of all of these, "action figure fighter" is probably my favorite, "robotish" is the best from a game-playing standpoint, and "dinobeeboxer" is just weird and cool.
Tuesday, February 21, 2012
death of the mouse: film at 11
"It's Time to Exterminate the Mouse" reads Mat Honan's Gizmodo headline, the lead feature for the site. And at the risk of sounding like a cranky old man, I think he has an extremely half-assed understanding of how people and computers interact. His whole tone is kinda provocative and juvenile, to the extent that the whole article feels like a troll. After a few potshots complaining about how 8-bit this hardware feels and how "anyone pushing them with new computers is selling crap" (NB: this point is stronger than it would be otherwise because he's tangentially talking about desktop systems, which are even more on the way out than mice..) he rhetorically asks:
He then gives examples of a gesture I agree with the utility of: pinch to zoom is pretty decent and intutive. And I think inertial scrolling is probably a bit better than the scrollwheel, and definitely (usually) better than manipulating a page pointer by finger or mousepoint.
Then he says
It goes on...
He then points to the Kinect as REALLY ahead of the curve with this stuff. Admittedly I was an early adopter, but using the Kinect to navigate the most simple menus is a nightmare. Each game invents its own paradigm for "select this option" (some use a swipe, some use a hold, etc) and for "back" and "pause". With the right game, using your body as the controller is fun as heck, but that's because you have a great mapping to a physical activity. (Ironically, the one place he admits to the superiority of the mouse is for FPS games. I was going to argue that the other way games have better interfaces is with the two stick controller and all those buttons, but then again each game has its own buttons to learn, and it only really works well because of the physicality of it.)
Other advantages of the mouse: has this guy ever heard of "gorilla arm"? That's what your arm feels like after a few hours of poke, poke, poke at the screen. For people who work long hours in front of a computer, you need something that's not going to tire you out. (Not to mention all the greasy fingerprints...)
Similarly, Mouse use on screen pointers. These pointers are nice because they keep state on the screen even when you put your hand down for typing. This allows bimodal systems that react to your projected interest (for example, hover states on buttons as you mouse around.) in a different way from your project intent (some form of clicking). Very few gesture systems carry that, and with the rise of touch devices, the hover state might be on its way out.
Also gestures tend to have poor discoverability. There are only a few universal moves (the zoom pinch, the swipe, the slide) and everything else varies greatly-- in fact, what a swipe "means" will vary from app to app. (Maybe if there was a universal "help I need the cheat sheet!" gesture?) So you get to a new app (or better yet to an old one you haven't used in a while) the answer to "how do I use this" might not be so clear.
Many gestures are residents of the universe of "moves the user can make unintentionally". Sometimes I mouse and shake a window on my Windows 7 machine, and suddenly all the other windows are minimized, including my chat windows and virtual post-its and things I like to keep around. And there's no real "Undo" for that, so I have to go and finds the things I wanted open. It's a clear violation of the Dao of UX, which is "a computer should always do that which surprises the user least."
So I might be sounding like that old "get off my lawn!" geezer. I might be underestimating the ability for gestures to standardize (they already are, like the "two finger scroll" on Macs) as well as having an exaggerated sense of the limitations of touchpads, since I often use these nasty tiny PC things that lack both the 2-finger-scrolling and the generous dimensions of Apple's Magic Touchpad... Still, I think this article is a overly provocative and insufficiently thought out or balanced. On the other hand, it lets me (and the majority of the Gizmodo commenters by the look of it) feel as if they're rather smarter than the author.
When was the last time you really loved a mouse? When was the last time you were like, "damn, this is a great mouse and I enjoy using it?"That's an easy one-- the last time I tried to do coding work on my laptop for a few hours. Going back to the mouse after a day on the touchpad is a blessed relief... stuck with just the touchpad for a day, an almost tangible pressure of annoyance builds and builds.
He then gives examples of a gesture I agree with the utility of: pinch to zoom is pretty decent and intutive. And I think inertial scrolling is probably a bit better than the scrollwheel, and definitely (usually) better than manipulating a page pointer by finger or mousepoint.
Then he says
Today at any given time we may be running 20 apps at once, with a dozen or more browser windows open, while trying to sort through more data in a few seconds than an early Cray supercomputer saw over the course of its lifetime. And yet we still use tools designed for a simpler time, with simpler needs.Which is true, but how is that an argument for gestures etc over the mouse? The iPad and the iPhone are lovely because they do ONE thing at once. In fact, much of the physicality comes from the way your glass slab has temporarily been turned a unitasking device for that activity. You need a lot of real estate to pinch and slide and poke.
It goes on...
Gesture-based computing gives us far more precision and control over the interface. We can manipulate not just points but entire screens. We can perform complex actions that once required keyboard shortcuts, with just our fingertips.Precision? Really? And keyboard shortcuts are nerdy but they are full of precision and control. Plus, you can see easily written descriptions of what keyboard shortcut goes with what command...
He then points to the Kinect as REALLY ahead of the curve with this stuff. Admittedly I was an early adopter, but using the Kinect to navigate the most simple menus is a nightmare. Each game invents its own paradigm for "select this option" (some use a swipe, some use a hold, etc) and for "back" and "pause". With the right game, using your body as the controller is fun as heck, but that's because you have a great mapping to a physical activity. (Ironically, the one place he admits to the superiority of the mouse is for FPS games. I was going to argue that the other way games have better interfaces is with the two stick controller and all those buttons, but then again each game has its own buttons to learn, and it only really works well because of the physicality of it.)
Other advantages of the mouse: has this guy ever heard of "gorilla arm"? That's what your arm feels like after a few hours of poke, poke, poke at the screen. For people who work long hours in front of a computer, you need something that's not going to tire you out. (Not to mention all the greasy fingerprints...)
Similarly, Mouse use on screen pointers. These pointers are nice because they keep state on the screen even when you put your hand down for typing. This allows bimodal systems that react to your projected interest (for example, hover states on buttons as you mouse around.) in a different way from your project intent (some form of clicking). Very few gesture systems carry that, and with the rise of touch devices, the hover state might be on its way out.
Also gestures tend to have poor discoverability. There are only a few universal moves (the zoom pinch, the swipe, the slide) and everything else varies greatly-- in fact, what a swipe "means" will vary from app to app. (Maybe if there was a universal "help I need the cheat sheet!" gesture?) So you get to a new app (or better yet to an old one you haven't used in a while) the answer to "how do I use this" might not be so clear.
Many gestures are residents of the universe of "moves the user can make unintentionally". Sometimes I mouse and shake a window on my Windows 7 machine, and suddenly all the other windows are minimized, including my chat windows and virtual post-its and things I like to keep around. And there's no real "Undo" for that, so I have to go and finds the things I wanted open. It's a clear violation of the Dao of UX, which is "a computer should always do that which surprises the user least."
So I might be sounding like that old "get off my lawn!" geezer. I might be underestimating the ability for gestures to standardize (they already are, like the "two finger scroll" on Macs) as well as having an exaggerated sense of the limitations of touchpads, since I often use these nasty tiny PC things that lack both the 2-finger-scrolling and the generous dimensions of Apple's Magic Touchpad... Still, I think this article is a overly provocative and insufficiently thought out or balanced. On the other hand, it lets me (and the majority of the Gizmodo commenters by the look of it) feel as if they're rather smarter than the author.
Subscribe to:
Posts (Atom)




