Outsmarting Your Users


by
19 Sep
September 19, 2012

Often times in the tech industry we believe ourselves to be smarter than the users of the technology we develop.  Or, at a minimum we believe we know our users well enough that we make certain design decisions base on how we believe they will use our technology.  This is not necessarily a bad thing in most instances.  After all, we are the creators of the technology.  It’s reasonable to assume that we know a good deal about that which we are creating.  At least, one would hope so.  :-)

Recently, I was working on an Android app where I needed to download a particular set of files. This task was fairly autonomous. I was content to start the download task and let it do it’s thing in whatever time it took.  I am aware of the fragile state of today’s <insert number here>G networks and was hopeful that I planned accordingly.  I would wait until enough of the first file was finished downloading before I used it in another task.  That however should not keep me from starting another task so long as I did actually plan accordingly.  I mean, really… who tries to use something before they actually have it?  Duh!

This is where my headache began.  I know now, after 4+ hours of banging my head against the wall, that prior to Donut (Android 1.6) AsyncTasks were executed serially in a single thread.  My first experience writing Android apps was with Froyo (Android 2.2.X), so I was not actually aware that at one point in time AsyncTasks were only executed serially.  You see, from Donut through Gingerbread (Android 2.3.X) AsyncTasks were executed on a pool of threads allowing them to run in parallel. I could be wrong, but I believe this to be the basic understanding of AsyncTasks.  You use them to parallelize your application and spin off tasks that do long running things while you continue to do other things.  That’s the “Kovach” definition.

Unfortunately, with the advent of Honeycomb (Android 3.X), Google decided that they would outsmart me and keep me from doing something stupid like trying to use a file in one task before it was downloaded in another task, and they changed the behavior of the execute() method on AsyncTasks back to it’s pre-Donut behavior were they all run serially in a single thread.  So now, my entire list of files needed to be downloaded before I could start using the first one in another task.

This was not the desired behavior! Remember, I said I’m more than aware of the fragile state of 3G/4G connections and I certainly don’t want to have to wait for 5 files to download completely before I start using the first one should that provide the best user experience in my app.

It wasn’t until after hours of Googling (ironic?) when I found the stackoverflow post about the change to the execute() method that I learned about an additional executeOnExecutor() method that was added to the AsyncTask class should I “truly want parallel execution”.  This little nugget would allow me to achieve the desired parallel behavior.

So, I’m willing to admit that I’m guilty of believing myself to be smarter than the average user on occasion. Again, I don’t necessarily believe that to be a terrible thing.  Side Note: I’m also more than willing to admit that I know nothing on occasion.  Just try not to be so smart that you frustrate the hell out of your users and end up looking stupid?

Aurelius

"I went to the woods because I wanted to live deliberately. I wanted to live deep and suck out all the marrow of life. To put to rout all that was not life; and not, when I had come to die, discover that I had not lived."

More Posts

© Copyright 2017 Findaway. All rights reserved.