Vincent Gable’s Blog

March 13, 2009

(Always) Showing a Window on Application Switch

Filed under: Cocoa,MacOSX,Objective-C,Programming | , ,
― Vincent Gable on March 13, 2009

Keith Lang said all Mac applications should show a window when you switch to them via command-tab or gestures. I agree. I do think it is best to show nothing when the last window is closed; otherwise closing a window might mean more stuff in your face, not less. But when context-switching back into an application I can’t think of a good reason why applications shouldn’t have something up that you can interact with right now.1

This is the behavior you get when switching between applications by clicking their icons in the dock. It’s unfortunate that you have to do more work for your application to behave consistently no matter how it’s switched-to. Here’s how I’ve done this in IMLocation,

In my NSApplication delegate I implemented - (void)applicationDidBecomeActive:(NSNotification *)aNotification to check if no windows were visible, and if so, put something up. Here’s the exact code I use, replace editCurrentLocation: with what’s right for you:

- (void)applicationDidBecomeActive:(NSNotification *)aNotification
{
	[self displayLocationWindowIfNoWindowIsOpen];
}
- (void) displayLocationWindowIfNoWindowIsOpen
{
	NSArray *visibleWindows = [[NSApp windows] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"isVisible == YES"]];
	if(IsEmpty(visibleWindows))
		[self editCurrentLocation:nil];
}


1Xcode, doesn’t put up anything when you click on it’s icon and you have turned off the “Getting Started” splash screen. This makes a bit of sense, because Xcode is a project editor, not a document editor. Projects are collections of many files, and having an “untitled” default one does not make sense. But by default Xcode shows a window, the splash screen. And there is an argument that it should show an empty file, like an Emacs “scratch buffer”.

March 10, 2009

Dashboards on Steering Wheels Are Complicated

Filed under: Design,Quotes,Usability | ,
― Vincent Gable on March 10, 2009

Given that all 11 F1 teams have converged on a remarkably similar UI (for a dashboard on a steering wheel), independently, you would think that (the style) was a rational design, however its complexity possibly caused Lewis Hamilton the 2007 F1 championship, when he accidentally pressed the neutral button …

825b387026c6c81ef5a96970ccd12ee8-orig.png

What is clear is that there is no clear accentuation of features (color, size) by how often the are used, merely by position. Even if drivers like Hamilton are experts and fully familiar with the UI, there is a tiny percentage chance of error. Our guess is that this trend in car UI would be a mistake if it filters through to everyday cars, and that F1 cars will revert to a more simple UI over time.

oobject.com (article includes a gallery of F1 steering wheels)

Certainly I have made mistakes with traditionally mounted dashboards in every car I have owned. But the mistakes haven’t significantly impaired by driving. Accidentally turning on the air conditioner or radio aren’t a big deal — even with my old Volvo that couldn’t accelerate as well with the AC on.

March 7, 2009

Don’t Work Against Yourself

Filed under: Quotes | , , ,
― Vincent Gable on March 7, 2009

Reaganite conservatism axiomatically disdains government, and that creates a perverse incentive for conservative politicians to run government badly (or at least not to run it well), since the failure of government confirms conservative prejudices and (in theory) provides the movement with additional evidence in favor of its ideology. We just saw a particularly vivid example of this pathologically self-destructive dynamic at work in Bobby Jindal’s otherwise inexplicable attempt to turn the Bush administration’s utter ineptitude after Hurricane Katrina into a GOP talking point.

Damon Linker

I generally try to keep politics out of my blog, because political discussion on the internet isn’t productive. But I think there is a good lesson in this bit of history, and it’s very applicable to software development.

March 6, 2009

A Good Basic Computer Science Book

Filed under: Announcement,Programming,Tips | , , , ,
― Vincent Gable on March 6, 2009

In high school, I literally wore out my copy of The New Turing Omnibus: Sixty-Six Excursions in Computer Science. The graphics topics are dated, and there is no discussion about newfangled topics in computing, like the internet. But the meat of the book are timeless computer science fundamentals. It still has the best explanation of what “NP-Complete” means (page 276) that I’ve run across.

The book covers some dense territory, but is still fairly accessible. When my mother asked me, “how can a computer make a random number, if it only does what it’s told?” I pointed her to the chapter 8, “RANDOM NUMBERS: The Chaitin-Kolmogoroff Theory” (page 49). The math was a bit over her head, but she could still read the chapter, and it answered her question. I recommend it to The New Turing Omnibus, without reservation, to anyone who’s considering Computer Science.

What are your favorite introductory Computer Science books?

Patrick Thomson suggests Godel, Escher, Bach: An Eternal Golden Braid. It’s an excellent and fun introduction to the essential theory behind computer science.

Here is an excellent overview of the current state of the P=NP question.

March 4, 2009

Professionals Check What They Broke

Filed under: Quotes |
― Vincent Gable on March 4, 2009

Mark Chu-Carroll, on how to tell if someone defining division-by-zero is a competent mathematician,

One good way of recognizing a crank is by looking at what they do with their new division-by-zero defining system. A serious mathematician starts working out what affect their definition has on the basic axioms, and what still works. A crank defines division by zero, and then proceeds to continue working as if they haven’t broken anything.

Mark Chu-Carroll

There are parallels in most every profession.

Retest Your (Low Level) Optimizations

Filed under: Programming,Quotes | , ,
― Vincent Gable on March 4, 2009

(Measuring before and after applying an optimization is) more important these days. With optimizing compilers and smart virtual machines, many of the standard optimizing techniques are not just ineffective but also counterintuitive. Craig Larman really brought this home when he told me about some comments he received after a talk at JavaOne about optimization in Java. One builder of an optimizing virtual machine said, in effect,

“The comments about thread pools were good, but you shouldn’t use object pools because they will slow down our VM.”

Then another VM builder said,

“The comments about object pools were good, but you shouldn’t use thread pools because they slow down our VM.”

Not only does this reinforce the need to measure with every optimization change, it also suggests that you should log every change made for optimization (a comment tag in the source code is a good option) and retest your optimizations after upgrading your compiler or VM. The optimization you did six months ago could be your bottleneck today.

Martin Fowler (PDF), 2002

I’ve written before about the decay of machine-specific optimization. Even if your code isn’t run by a VM, I think it’s reasonable to expect that (at least some of it) might be run on a smartphone in the near future.

March 3, 2009

Vincent’s Notes: End To End Arguments in System Design

Filed under: Programming | , , ,
― Vincent Gable on March 3, 2009

At Michael Tsai’s suggestion I listened to the paper End-To-End Arugments in System Design while driving. (Fair warning: Since I was also driving while listening, I didn’t absorb everything as well as I should have.)

The thrust of the paper is that you generally want to make your low level components (aka libraries) simpler then you think. Counter-intuitively, building extra reliability into a low-level component does not (usually) make it easier to build a reliable application that uses the component. That’s because the application has to work around all sorts of other errors from different components. So it must have error handling code. Making one low level component “smarter” does not change this. But it does make the component more complex. And some of that complexity is duplicate code that does just what the application’s error handling code does.

The “End to End” in the title of the paper is from a file transfer application having to do an “end to end” check to make sure that the files at both end of the transmission are the same.

Conclusions

End-to-end arguments are a kind of “Occam’s razor” when it comes to
choosing the functions to be provided in a communication subsystem.
Because the communication subsystem is frequently specified before
applications that use the subsystem are known, the designer may be
tempted to “help” the users by taking on more function than necessary.
Awareness of end-to-end arguments can help to reduce such temptations….

March 2, 2009

Initial Findings: How Long is an (English) Word?

Filed under: Research | , , ,
― Vincent Gable on March 2, 2009

My brief research into the English language revealed the average character count of a word is eight. Throw together a bunch of a smaller and bigger words, some single spaces and punctuation and you roughly end up with the average 140-character tweet being somewhere between 14 and 20 words. Let’s call it 15.

Rands in Repose

That contradicts the common wisdom I’ve heard: the average word is 5 letters, so divide your character count by 6 to get a word count.

But that was a rule of thumb from the days of typewriters. Hypertext and formatting changes things. For example, every time you see something in boldface on my blog, there are an extra 17 characters for the HTML code, <strong></strong>, that makes the text bold.

Just to poke at the problem, I used wc to find the number of characters per word in a few documents. What I found supports the 6 characters per word rule of thumb for content, but not for HTML code. The number of characters per word in HTML was higher then 6, and varied greatly.

The text of the front page article on today’s New York Times was 5880 characters, 960 words: 6 characters per word.

The plain text of Rand’s webpage claiming 15 chars per word was 6794 characters, 1175 words: 6 words per character. By plain text, I mean just the words of the HTML after it was rendered, so formatting, images, links, etc were ignored. The HTML source for the page, however, was 15952 characters, meaning 14 words per character.

What about technical stuff? The best paper I read last year was Some thoughts on security after ten years of qmail 1.0 (PDF). It has no pictures, just 9517 formatted words. A PDF represents it with 161496 bytes (17 bytes per word), but ignoring formatting it is 62567 characters (7 characters per word).

I’m still looking into how long English words are in practice. Please share your research, if you have an opinion.

February 24, 2009

More Flash Hate and Graceful Degradation

Filed under: Accessibility,Announcement | , , , ,
― Vincent Gable on February 24, 2009

Adobe’s website for Air (their cross-platform ‘web for the desktop’ technology) requires Flash 10. If you have an earlier version of Flash, like 75% of the visitors to my website, then you see a big blank box.

This is a terrible mistake for the company that makes Flash. In no way does it inspire confidence that Flash is accessible.

The real irony is Adobe’s own website was the first website I’ve seen that was incompatible with the version of Flash I was using. If other websites leveraged Flash 10, they gracefully degraded so that I could use them with Flash 9.

When I finally upgraded, I couldn’t see why Adobe’s website needed Flash 10 was required. I wasn’t wowed. All I saw was some fancy transitions between slow-loading flash videos.

Just by being open, that one website used 125% of my CPU even when I wasn’t interacting with it. No joke, 125% is what OS X reported. I am using a dual core machine, so the 125% means that 100% of one CPU, and 25% of another were used — just to render a webpage I wasn’t even looking at.

Is Adobe fine with alienating 75% of the internet?

Why can’t they make their own website laptop friendly?

Why should I trust their new Air platform that “lets developers use proven web technologies” if its own website won’t just work for me?

February 23, 2009

Why You Need A Blogging Program

Filed under: Announcement | , ,
― Vincent Gable on February 23, 2009

I highly recommend using a desktop blogging program. Obviously they make blogging easier, but more importantly they remove friction from recording and sharing your great ideas.

I use MarsEdit to write this blog. Honestly I don’t know if there’s something better out there. I tried it because it was mentioned by people I read. It worked well enough for me that I never went looking at competing programs, and when the free trial was up I paid for it.

All of the Internet’s Strengths, None of its Weaknesses

Some benefits of using a desktop blogging program are obvious. You can do everything you can do with your blog’s web interface and more. The whole writing experience is just a bit more snappy and polished when you take full advantage of the computer you’re writing on with a native application.

Getting the Computer Out of Your Way

But the less-obvious benefit is that a blogging program makes it easier to jot down ideas. Whenever you want to write something, you just hit “New Post” and start writing. You don’t have to name or categorize your post until the time is right. That may not sound like a big deal, but it’s huge in practice. As John Gruber explains in detail, having to deal with the filesystem just to jot down an idea is a lot of friction.

…(the) problem is that the mental friction posed by the Save dialog often keeps you from ever even creating or saving small items of data in the first place.

MarsEdit lets me just start typing when I have a new idea; and quickly find old ideas when I want to build on them.

Do Something With Your Ideas

There are lots of dedicated “notes” applications that “get the computer out of the way”. Blogging apps are superior to all of them, because they make it easier to do something with your ideas. Using another program to keep track of ideas is another barrier to actually publishing them.

You might not want to share every idea, and that’s fine! Just because you’ve written it down in a blog editor does not mean you have to hit “post”. I would love it if you built your secret idea and got rich off it. No lie. If you make something amazing enough to make a fortune, then you’ve made a difference in people’s lives. And I think that makes the world a better place.

But for most ideas, an essay is still the best way to change the world, because it’s the best way to change millions of peoples minds. Using separate programs to track and publish of ideas is another barrier to actually publishing them. Blogging programs make it easier to get the most out of everything you write by removing this barrier.

« Newer PostsOlder Posts »

Powered by WordPress