API Design

The latest post from Matt Gemmell is a must-read for Cocoa developers. I find myself thinking a lot about APIs when writing code, for all classes, even “internal” classes.

However, I noticed this delegate method in the section If a convention is broken, throw it away:

- (BOOL)isTileEnabled:(NSInteger)tileNumber inMenu:(MGTileMenuController *)tileMenu;

I think the naming is confusing. It could be confused for an accessor method, which would return the current state of that tile. Yes, I know, it’s a delegate method, so it would not make much sense. Still, I would have instead used the following name:

- (BOOL)shouldEnableTile:(NSInteger)tileNumber inMenu:(MGTileMenuController *)tileMenu; 
Worked for me at first try. Maybe it’s because I have a French accent. Or Apple tweaked Siri’s servers after this was published?

Worked for me at first try. Maybe it’s because I have a French accent. Or Apple tweaked Siri’s servers after this was published?

iPhone 4-inch

It looks like the new iPhone will sport a new 4-inch screen, as rumors have become more and more believable. Keeping the same pixel density would ensure that production and operations can rely on the current manufacturing setup. Switching to 1136 x 640 would be as close as you can get for a 4-inch screen and a 16:9 ratio.

It should be straightforward for developers to support both the old and new resolutions in their app. Xcode (and Interface Builder before it) have gracefully handled variable screen sizes for years on the Mac. The same principles can be used on iOS. Keeping the same width actually makes the transition easier, as vertical scrolling is the main navigation mode in most apps.

But what about legacy apps, that were not written with a larger screen in mind? Will the OS simply stretch the elements that it estimates can potentially be stretched? The OS could decide for instance to stretch table views, but keep toolbars a the same size. There is however still a risk that too many apps will become unusable because of wrong assumptions.

There is an alternative: “legacy” apps could simply run in a small portion of the screen. This is similar to what Apple did with iPhone apps on the iPad, except it’s going to look much better with only small bands of unused screen on the top and bottom (unused and insensitive to touch). This solution has worked before, and provides the safest transition for Apple and users.

There is only one caveat I can think of. For black iPhones, this will be almost invisible. For white iPhones, it might be more glaring. For this reason, the app content could be centered in the screen, instead of being consistent with the previous iPhone model. Keeping the position consistent with the old iPhone would make sense in terms of usability but might get in the way of aesthetics.

Why “The Guinea Pig in The Coal Mine”? Because I think it’s a truly hilarious name. And a Google search with the phrase “guinea pig in the coal mine” comes back empty. So expect a hilarious but empty blog.