2014-08-08

Cocoa documentation has an image that tickles me.


It is from the Cocoa Core Competencies document, in the section "Object Creation". I like explaining things by analogy, perhaps too much because my analogies do not always work. I think this one gets the point across. It is understandable across all modern computer-using Earth cultures. I like it. It is effective and well done.

However, I would display the resource picture as bills of currency and the allocation as the individual ingredients, and I would remove the dough mixer. The resource is the computer's memory, not your code pieces and data parts (ingredients). Allocation is when you claim some memory and fill it with your code and data (convert your currency into flour, salt, yeast, and water). The way the analogy is now, it doesn't emphasize enough the conversion of a homogenous limited resource (memory/money) into a useful item. In fact, it shows that your methods and instance variables (flour and yeast) are the resource, and they aren't.

I don't think my imagined changes would help a beginner understand OOD/OOP better. I just think it would make the analogy more accurate. Are computer engineering basics taught to computer programmers these days? If yes then perhaps a more accurate analogy would help after all.

Has anyone written a class that has an initWithTemperature: method?

2014-07-10

Stop using icons.

I am writing this in the month of July in the year two thousand fourteen of Anno Domini / Common Era.

I was using Google Chrome 35.0.1916.153 and Mac OS X 10.9.4.

I clicked a link in Chrome pointing to a PDF file. The file displayed in a Chrome tab. I just wanted to save it locally. This floating toolbar was in the bottom right corner of the screen.


I recall the era of the 3½ inch floppy disk. As a teenager, I used 5¼ inch floppy disks to load programs into my Atari 800. In the 90s, we used Zip drives and later Jazz drives.

But come on! I had to hesitate far too long hovering over that button (with no tooltip) wondering if it meant what I hoped it meant. I was also anxious it would do something destructive and annoying to reverse.

I think my pause was due to two factors: I had not seen a floppy disk in so long that I was not sure if the silhouette matched one, and I was in disbelief that a modern UI designer would use this image to represent "save".

The only icons I recognize on that toolbar are zoom out and zoom in. I've got a crazy solution. Look at my Gmail message-level toolbar.


2014-05-07

My image editor for Mac OS X is now Acorn.

I moved from Linux to OS X years ago, but I still kept going to GIMP for image editing. Keep in mind that only in the last year or so has GIMP become Cocoa-native. Prior to that it required an X11 runtime that was available as an installable extra from Apple.

Running GIMP inside X11 on OS X looked poor with the antiquated GTK+ widget set. The runtime situation made it impossible to directly Alt+Tab to GIMP; the X11 process would gain focus instead. The GIMP shortcut keys used Control instead of Command. There we other quirks I cannot remember now.

When GIMP become Cocoa-native, I was relieved. But a keyboard focus bug caused text entered into text fields to be interpreted as Alt+Key strokes, which are shortcut keys for menu items. Fine, so I disabled all shortcut keys in the app and did everything solely from touchpad clicks. In the next version, that bug got fixed but not the bug that fails to order files by name properly.

Yesterday, in GIMP, I was trying to figure out why I could not select a layer in the Layer dialog. I had already converted my floating selection to a new layer, so what could be the problem? GIMP hung as I poked around, and I had to force quit it. At that point, I decided to buy an image editor.

I had previously researched other image editors for Mac OS X, but the different choices were daunting. The review articles I had found were either outdated or incomplete (missing a prominent application). Finally, in a bogus article which I will not link to, several comments to that article recommended Acorn. I took a look at the feature list of Acorn, and I was impressed. It only cost $30, and I trust the crowd more than a self-appointed authority on those user-generated content repositories, so I bought it.

What a huge difference! I am still in the process of kicking myself for being so foolish as to not leave GIMP earlier. I rate GIMP's ease-of-use at 3 (out of 10). I rate Acorn's at 9 (because nothing is perfect). Exploring Acorn to figure out how to do something is fast, simple, and straightforward. I had to look up how to add to a selection, and the Acorn documentation is up-to-date and complete with good search results.

And that brings me to what really struck me about the difference. In GIMP I had seen the different selection method (add, subtract, union) mini-buttons before, but until Acorn it was all just so much clutter in my face that I never thought about what to do with those buttons. So suddenly, because of Acorn's superior UI design and full documentation, my skills as an editor of images have increased.

For those of you thinking I should use Photoshop, Photoshop Lightroom, or Photoshop Elements: just no, guys. I think I tried out Lightroom, and what a convoluted mess. The install was odd somehow. The look and feel was that wannabe nouveau Adobe Flex. It tried to take over my Mac by asking me about all my images and whatnot. And the UI was like advanced GIMP. I went running back to GIMP very quickly. The next time I tried to give Lightroom another chance my trail period had expired, and I decided it was not worth it to pursue again.

To those who might think this product review was unfair: I did not set out to write a product review when I started using PS Lightroom, Acorn, or GIMP. I'm just a guy who used GIMP on OS X for far too long, and I used the immense power of an inference engine that I keep stored in my skull, and the output I got from the input provided lead me to spend $30 on Acorn, and I'm very happy with that decision. In fact, I'm so pleased that I wrote this blog entry about it.


2014-02-17

My iPad app is available: Veronica's Garden Tracker.


Please tell every gardener you know about Veronica's Garden Tracker for iPad. Thanks!

I aimed to create a simple, visual journal for home vegetable gardens. I got the idea when I asked my wife a few years back, "Sweetie, what is this sprouting here?" and she had forgotten and her labels were missing, so we had to wait a few weeks until the plants got bigger to find the answer.

Google AdWords redeem coupon code screen has moved.

It took me a bit to find the new location to redeem those promotional codes that Google hands out to lure in folks like me into using AdWords. All the blogs out there talk about the old, easier-to-find location. Even the email that contains the promo code itself is wrong.
  1. Starting from AdWords home.
  2. Click gear icon in upper right.
  3. Click Billing from drop down menu.
  4. Click Transaction history.
  5. Click More Actions button.
  6. Click Apply a promotional code from the drop down menu.
  7. And there you are!

2013-12-11

Order that UIScrollViewDelegate methods get called when a user does a sloppy tap.

Please note that the UIScrollView I am using has pagingEnabled set to YES.

To create the sloppy tap gesture, the user makes the most minor drag motion possible with his finger. I call this a "sloppy tap" because about 1 in 10 of my own taps trigger this gesture on my iPad 2. Visually, the scroll view will not appear to move.

  1. scrollViewWillBeginDragging:
  2. scrollViewDidEndDragging:willDecelerate:
Note that scrollViewDidEndDecelerating: will not be called because no scrolling actually happened.

Here is what gets called when a user properly flicks his finger horizontally to scroll to a new page.

  1. scrollViewWillBeginDragging:
  2. scrollViewDidScroll: × ~4
  3. scrollViewDidEndDragging:willDecelerate:
  4. scrollViewDidScroll: × ~24;
  5. scrollViewDidEndDecelerating:
Suppose you want a flag toggled as soon as movement starts, and then you want it toggled again only after movement stops. There isn't one method you can count on for the second flip.

I already toggle the flag in scrollViewWillBeginDragging: and scrollViewDidEndDecelerating:. The solution is to also toggle the flag in scrollViewDidEndDragging:willDecelerate: when decelerate is NO.

I would have figured this out sooner if I had read the documentation more closely.

2013-12-06

lldb and Objective C: printing structs contained in objects.

I'm tired of looking up how to do this.

Wrong:
(lldb) expr -- self.scrollView.frame
error: unsupported expression with unknown type
error: unsupported expression with unknown type
error: 2 errors parsing expression
(lldb) expr -- (CGRect)self.scrollView.frame 
error: unsupported expression with unknown type
error: unsupported expression with unknown type
error: C-style cast from 'unknown type' to 'CGRect' is not allowed
error: 3 errors parsing expression

Correct:
(lldb) expr -- (CGRect)[[self scrollView]frame]
(CGRect) $5 = origin=(x=0, y=0) size=(width=768, height=607)

You'll notice I don't bother with gdb aliases like p. Please accept my apologies.