Saturday, January 7, 2012

Always Test in Real - Not Just Crappy - User Device

Memory related defects can be hard to debug, therefore I usually force automatic system "out of memory" notifications. That makes sure I have no other choice, but to handle potential OOM issues from the start. Otherwise the app won't run. Clever, right?

And that's the problem. Potential OOM issues. Did you notice that "potential" keyword?

Just found out that my application didn't work as expected in real device - because there wasn't any "out of memory" situations! UIViewController didn't get killed, thus it wasn't recreated next time from scratch! Boom - app crashed!

"Always test in real device" is as old phrase as the whole software industry. I do that, using as old, slow, poor, cheap, worn-out, crappy, memory limited, CPU challenged, disk stuffed hardware and environment as possible. Yes, I do remove SIM card, while app is running. And eject memory card, while app is streaming 10GB video on it. And put mobile phone in sink to harm signal reception. And try to write 1000000 character long username in registration field. Love crashing unsuspecting apps. 10+ years as (undisclosed) subcon taught me well that Mobile. App. May. Not. Crash. Ever. No. Matter. What.

(That was before excel-sheet pushing bean counters invented far-shore outsourcing. Before apps started crashing. Occasionally).

Somehow my subconscious has started to pre-optimize that hardware testing phase by trying to catch bugs that I KNOW will be found by trying to emulate the crappy hardware in development environment.

Never pre-optimize. Never over-optimize. Never guess-optimize.

The problem is... WHAT IF there is no problem? What if everything just works as it's supposed to work? What if your code, which can handle all the things that can go wrong, cannot handle a situation, when things don't get wrong!

AARGH !!!

8 comments:

  1. Hi Sir iam new to iPhone development , i started learning my self, and i start developing app now but i am getting more problems. can u Please help me.

    this is what i am developing

    frist view is tabBars with table view,searchBar , when i successfully loaded my plist data into my tableView and detail view but i am not able to seach the TableView data.

    thanks for helping. Pavan. pavan_apple@yahoo.com

    ReplyDelete
  2. Apple has released as part of iOS SDK documentation a sample app just for table search (http://developer.apple.com/library/ios/#samplecode/TableSearch/Introduction/Intro.html)

    ReplyDelete
  3. hi sir here my question.

    can u give me iPhone app development online training.

    quation about my app :

    sir i have 3000 contacts of employes with details : i have to show them in my app. in first view controller, i want set searchBar with tableView. when user tap on tap on tableview cell pass the data into detailView controller.in detail view i want show all the information about the employee(photo,name,adress,phone,fax,and email ID). in detalView when i tap on the phone number it will dail, and same email also it will compose. please guide me to start .I understad how Xcode will work but the problem is in the programming .

    Please help me sir i will be very Thankful and Honest.

    ReplyDelete
  4. What you describe is pretty easy, should be possible to find that via google. Since you said you're "new", I recommend reading some books e.g. from Pragmatic Programmer (http://pragprog.com/).

    As for me and online training: this blog is my hobby, at daytime I work as pro iOS developer and am currently fulltime in business iOS client-server project. Sorry, no time for training..

    ReplyDelete