Thursday, March 10, 2011

Owning a tablet - is it in your future?

I have noticed a couple of things since getting an Android phone. First off I search for stuff on the internet a lot more. This is mostly due to easy access. I was sitting in the car waiting on my son to come out from his clarinet lesson and I spent most of the time on the web looking for birthday presents for my other son. As I found something interesting I did a long press, Share, Email sequence to send it to my wife to discuss later. Worked like a charm.

I do crossword puzzles at home nearly every night. Something you can pick up, work on for a bit while waiting on some aspect of food to cook, put down and come back to later. I will look up answers on the web to obscure things like "author of book {book name here}". Personally I am not a fan of those types of clues but they do turn up often in the more difficult puzzles. Phone works pretty good for that even though I long for a keyboard.

In the car the kids may ask a question and we will look something up. At night while watching things on TV I might want to check out DZone, SlashDot or some other tech site. Maybe I am researching something or looking up information on a home repair. I can do it on my phone in the living room as most of it is content reading. Nothing to fire up, phone is already on so pretty much instant access. Maybe I will switch to a game for a few minutes or check out LOL cats as my son is brushing his teeth getting ready for bed showing him the funny ones. Nice way to unwind the night.

A few friends and neighbors now have tablets. At first I really had no desire to own one. First I don't think I could bring myself to buy something from Apple as they annoy me and second there is the cost. Of course the more both my wife and I use our phones the more I can see a tablet being really handy. My wife really likes to read, text and email at night in bed. I tend to fall asleep well before she does. Laptops are a pain, tablets seem to be about the right form factor.

I tend to be a cheap bastard so I am not looking at the Xoom at this point. I also realize the truly cheap ones will be super crap and most will not have access to the Android Market which is a must. Finally I really want it for in the house so I want WiFi only as I don't want to pay for another data plan. I would love to share my phone for 3G access to use on the road though. I could see it being used by the whole family for a number of activities. Could be one of those things we fight over enough that we end up picking up another one. Kind of like the DVR, once you have one you pretty much end up with more of them.

Just doesn't seem like the Android tablet market has quite shaken out. I like the size of the Samsung Tablet, the 7" size seems to be a good hand size especially for eBook reading. 10" appears to be a bit big but I have not used one enough to really know. I think we are going to get an iPad 2 at work and since I will be the lead developer on that I should get a good chance to check it out.

I also hate to be behind the technology curve by too much. The minute you buy one you are screwed. Never know if they will update to the next Android version. Best to get one with a version you can live with. Is 2.1 or 2.2 enough on a tablet? Will I drool over 3.0 and the dual processor speed? If it really is for web browsing and email then the older version are more than adequate. I will play games on it and newer games might not work on the older stuff which would really stink.

Don't think now is the time to buy. Let more come out, let some go on sale, let the rules change so a device that does not have phone support is still allowed full Android Market access. Check out who is willing to update OS versions and who abandons you once the check clears.

Yesterday I install the app I am writing on a Samsung Tablet owned by our QA lead and I got a chance to play with it for a bit. The screen is not as nice as my phone, not a big surprise as that would be a really big expense, and the glare of the office fluorescents does not help but it seems like a nice tablet. Excellent size, fast enough and familiar as it is same OS version I use. Wanted to see Angry Birds running on it out of curiosity but that was not to be. He got a deal on it at Costco and is really happy with it.

Best just bide my time...

Friday, March 4, 2011

More fun with mobile development

My quest to get both the iPhone and the Android  applications in sync and released continues. Of course I find more differences every day.

I have set up the Android SDK and emulator for the BA on the project. This has been a great help. She can test the program without a physical device and can grab screen shots for documentation. It has not been great in that the emulator snapshot functionality has bitten us repeatedly.

Why use snapshot? If you don't it takes a long time for the emulator to fire up. Not very friendly when someone stops by for a quick demo. I think the best settings are as follows:

  • Tell the virtual device you want to use snapshots on its edit screen or when initially created
  • Start emulator and tell it to "save to snapshot" on exit
  • Once it starts turn off Japanese keyboard stuff (not sure why this is on by default always)
  • Install your APK files via adb
  • Shut down emulator
  • Start emulator, select "Launch from snapshot" and turn off "Save to snapshot"

If you continually have it save to snap shot it will corrupt the snapshot at some point. This has happened to me repeatedly. The second bit of fun, when you delete a device it does NOT delete the snapshot. This means if you delete the device then create a new one with same name you get the old corrupted snapshot to kick in. You can manually delete them in the {user dir}\.android directory. The AVD manager should really take care of this. This does mean when I update the APK I need to get a new save snapshot after I install it. Means I can't automate that process which stinks.

I added a menu to the Android app with and About and Logout buttons. Very easy to do and I love having access to a menu button always on the phone. It also makes it easy when you are helping someone with their device - "Hit the menu button" is easy but "Find the menu somewhere on the screen or get out of the app and go all the way back to Settings to see if there are settings for the app you just closed somewhere in there" is not as friendly.

On the iPhone side you are on your own when it comes to coding. I decided to add a button to the title bar off to the right. On the iPhone the left side is used for the "back" button, the middle for the name of the current view. Makes more sense to me to have the back and menu buttons off the screen the way the Android did it but on the iPhone you have a bit of text telling you where "back" will go. Of course you can do the same thing on the Android if you so choose, Apple just does not give you a choice, one button to rule them all! Reminds me of their battle to avoid two button mice for the longest time.

What should logout do? Turns out closing an app on the iPhone will get you rejected from the app store so that is not an option. Returning you to the login screen appears to be the way to go. On the iPhone the user MUST be the one to press the HOME button to close an app. Of course that does not really close the app anymore depending on what device you use but we better not use the fragmentation word as it only applies to the Android right?

I spent a good deal of time this morning on Stack Overflow to find this line of code:

[self.navigationController popViewControllerAnimated:NO];


When they select logout from the popup menu the view needs to close. Not that I would have figured out this line by scanning the API documentation. At least it is one line of code and not too contorted. I then added a global variable (shudder) to the main control so each view could check that and if we are in the process of logging out we also close ourselves during the view will appear processing. When we hit the Login screen it does not close but instead just clears the variable. Working like a champ during my testing.

This does bring me back to the evil "fragmentation" word. It is thrown at the Android side of things all the time due to screen resolution and other hardware differences. Yes, I have code in my app to handle these differences. No, it is not fun to write and test. Yes, I have an emulator that helps. No the emulator is not a job to work in.

What about on the Apple side? You have various OS versions with some being multitasking and others not. Just tell them to upgrade right? Wrong, some are now stuck at a revision. The second generation iTouch that I use for testing just got added to the stuck list. I already have code in place to check for multitasking in our app. I have been affected by iOS fragmentation.

The new iPad is said to be really speedy compared to the old one. I had lunch with a friend yesterday who expressed concerns with their iPad app and timing issues. Even the simulator in Xcode now lists multiple options - iPad 3.2, iPhone 4.0, iPhone 4.1, iPad 4.2 and iPhone 4.2. They just released GM of 4.3 so I will need to grab that too. The simulator runs a ton better on the Mac than the Android emulator on the PC but it also gives a false sense of speed.

Let's just kill the fragmentation rhetoric. It affects every developer no matter the platform. We have dealt with it for years. It is affecting Apple more than they care to admit. It may limit them from doing a smaller screen iPhone nano. I know not to hard code to screen resolutions but I do see sample code that does on various websites when looking up iOS issues.

You can tell me tablets and phones are different beasts and I will agree. You should not just scale up your phone interface for the tablet, it should become a new fuller featured interface instead. That is one of the early bitches about the Xoom, not enough native applications. Even tossing them into two buckets you still have fragmentation due to iOS differences due to lack of upgrade options. I don't want to see these old devices in the landfill.

Both Apple and Android have fragmentation. It should no longer be listed as a Pro or Con when deciding with camp to join. End of rant.

Wednesday, February 23, 2011

Second iPhone provisioned and optimized Android code

It looks like all the adjustments I made in Xcode to the project file paid off. I was able to easily provision another phone today for our Business Analyst. I did the update to the provisioning profile in Organizer, plugged in her phone and did a Run. The application copied over right away. She can now do screen shots for promotional material for both the iPhone via her own device and for the Android using the emulator.

On the Android side of things I noticed it was taking a long time to deal with some server data. I finally had the chance to check that out today. I put in a new timing object and looked to see where the hold ups happened to be. It was not in the server call itself, the XML data came back in under a second, but it was in the XML parsing. We are using the XML Pull Parser that comes with the Android SDK. Listed as just a little slower than SAX and much faster than DOM.

I figured out how to do profiling via traceview and found the slowness to be in our start tag processing code. I looked over that code and eliminated an unneeded StringBuffer, over creation of an ArrayList object, some string comparison clean up, removal of instance of check and some if statement cleanup. I was able to cut the parsing time from ~20 seconds to ~6.5 seconds in the emulator. It runs in ~2.2 seconds on my Galaxy S phone. I still want it faster but this is a huge and very noticeable speed improvement. I need to run similar timings on the iOS side of things. My iTouch is out in QA land so I can only test in the simulator at this point which can be very misleading.

I need to take my optimizations and move them into the main branch of our desktop Java code. Speed improvements always help - well as long as they don't break something. Fast and broken is still broken.

At this point I have the two mobile apps running pretty smoothly and graphically pretty close to the same where it should be and different in places where it does not need to be. I did more tweaking on the lower DPI screen in the emulator for the Android to get the look we need. I adjusted some HTML code on the iOS side to give a better layout look. Very happy with the results. They can start using screen shots for the glossy promotional stuff any time.

Tuesday, February 22, 2011

One iPhone provisioned

I made a number of updates to our iOS application including some related to multitasking. Everything was running fine in the simulator so I needed to put it on the iTouch to verify things worked sans multitasking. No go. It decided the profile was screwed so I could not install it. I found an old profile and deleted that but still no go. Looked on the web and found you have to manually open the project file outside of Xcode and remove the old provisioning lines. Gee thanks Apple for not even fixing this in Xcode 4!

I installed JEdit on the Mac for simple text editing via a free editor some time back. Wish I had PSPad but this serviceable. After you figure out the project file is a directory even though it does not look like one and you do a right click and Show Contents you are able to see the project file. I made a copy in a backup directory then I removed the provision profile line and saved it.

Fired up Xcode but it still was annoyed so I opened the plist file and set everything in the Code Signing Identity to automatic iPhone developer and it finally worked. Since I had success on the iTouch I asked the QA person to try their phone again and it installed without a hitch. Somewhere the Gods shown upon me today and I was able to get two devices working with minutes of each other. Nice sense of accomplishment but really people, this should not even need to be discussed, it should just work.

My next worry is also related to hardware. We plan on getting a new Macbook Pro when the new line ships this week (wink wink nudge nudge) according to the rumor mill. Will I be able to move over the profiles? Will everything go down the toilet? Will Xcode 4 hate the new hardware and just go belly up? The answers to these and other mysteries next week. Might need to call Robert Stack. That would get a great Mac website for questions - Robert Stack Overflow. I am very nervous this is going to be a massive cluster. Apple has given me no reason to believe otherwise. All experiences thus far have lead to non-working code releases with every attempt to do anything logical.

Today I move back to the Android to make similar changes. I already have the multitasking changes in place, that was easy, but need to do some minor UI tweaks to get them in sync. I really have no fear of any issues on that side. It will just work as it has in the past.

Monday, February 21, 2011

Xcode 4 crashes a lot

I have been updating our iOS application and I am using Xcode 4.0 Gold Master. It crashes at least 3 times a day. I just hit [Continue] and move on but this is not a good omen for a Gold Master. I have never been in the loop during an Apple Gold Master experiment so I don't know how responsive they will be to fixing things. I am curious to see what happens. I figure I get the privilege of downloading the entire 3.8g of Xcode fun if they fix anything as so far Apple does not appear to deal in patches like the rest of the industry.

Skipping the crashes I like the changes made to Xcode. Being able to keep multiple files open in tabs is very handy. Once you find things that have moved about they appear to work as expected. It is faster for what I am doing. There are more warnings to help clean up your code. I love the integration of Interface Builder.

I really wish the code completion would start right after you hit '.' instead of waiting for you to type the first letter. I don't know what I am looking for always so I have hit Ctrl + SPACE a lot. I am still new to the whole iOS thing so I did not know a CGRect did not have a width but it had a size.width. Waste of time / keystrokes to not have the IDE help you in this area. Is there a way to enable this somewhere?

It still takes me a bit of time to find help on the Internet. Seems like I just don't think the same way or use the same words to describe things as Apple does. It usually takes 3 searches to find what I want whereas when I search for things in Java or C# I almost always find the results in the first search set. It really gets frustrating. At times I wonder if they try too hard to be different.

Off to figure out applicationDidEnterBackground and applicationWillEnterForeground so I can refresh data on phones that support multitasking.

Saturday, February 19, 2011

Technical challenges when switching jobs

I changed jobs in October for the better. The old place was full of politics and alcohol. Since I have a family and don't have time to drink every night after work I really did not have a chance to move up and I got tired of doing the work but getting none of the credit because I was not a drunken sod. Add to that the anti-Java mentality and it became a hostile work environment. In the 14 year history of the company a Java developer was never named employee of the month even though the Java product was around one half of company licenses. The other half of licenses was based on the C++ product.

The new job pretty much involves getting work done which I really like. Of course it has been mentally challenging for sure. I worked at the old place for 4 years so I knew the software inside and out. I had pretty much rewritten a good portion of it before I left. It needed it in that there were performance issues, the code was not using Java Generics and it really was not very object oriented. If I never see code like parent.parent.parent.parent.setEnabled() again that will be too soon. You may laugh but this was all over in the code and you never knew what each parent happened to be but pretty much everything had a variable named parent.

Previously it was all Java all day with just a little bit of C# mixed in for some utilities I wrote, just to keep my skills up, they could have been written in Java.  Later there was more C# done very poorly by a new team.

Now I program in Java using MigLayout and JIDE on the main application, Java using the Android SDK, Objective C for iOS, SQLite on both Android and iOS and HTML on the iOS. On a lot of days I switch between all of them. Plus I am learning a new industry and a new Ruby based server. When I see a combobox I know how to fill it in but I may not understand the data. I will see a name of a file in the source tree but I might not know how to get that dialog to appear when running the code. I also use multiple IDEs - Eclipse, IntelliJ and XCode.

Honestly just switching out one language, server API or IDE can wear you out but to do them all at once is a shock to the system. The other team members know the server, IntelliJ and the main Java stuff very well so I can always ask for help in those areas and they gladly offer up advice. The code is well written and has been easy to jump in and be productive. I came from 4 SPACE indent and braces on a separate line to 4 SPACE indent with braces on the same line but that seems to toggle every job I take and it just does not bother me.

On the Android side one team member has done a little work there and he wrote the base of the application I am working one. It is great to have the server communication in place. I have polished up the UI and am now working on the next major enhancement. He is a great sounding board for ideas as he has used the API.

On the iOS side no one but me has done anything. The guy who wrote the initial application left to start another company. The code is oddly written and not commented. I have cleaned it up the best I can, have commented it and have addressed the open bugs. I end up on Google searching a lot during the day and don't always feel very productive.

During the various interviews for other companies I got turned down because I did not know SQL well enough or I had not written a full blow application using technology X. I have worked with a number of excellent programmers and I know technology can be picked up rather easily. Once you are at a company you will almost always have to learn something new. The new place gave me a chance because I had solid Java skills and was willing to give the other stuff a shot. The other team members did not want to mess with iOS but I figured what the heck. I don't revel at the thought of coding with Objective C in Xcode but I am learning a lot.

The SQL barrier always annoyed me. I was told after numerous job interviews that they wanted someone with more SQL skills. I was probably too honest in the interviews about my skills. I don't like to oversell. I know SQL but I am no master. I am not the person to go to for performance tuning on a query. I can't rattle the benefits of inner and outer joins. I can read the code, I can query the data but I have had a DBA get things set up. I enjoy GUI programming much more than server side programming. When I asked how much actual SQL a developer wrote during a week they would admit there was not a lot. You were mainly using what was already there, just like I do pretty much every place I have worked. They just had this desire for everyone to be an expert in it. Companies need to wake up and hire excellent programmers not just people who hit a check list. I would not want to be hired as a DBA but that was not the job description. Their loss.

I am using SQLite on both the Android and iPhone side. Granted this is limited SQL work. I am not setting up a huge number of tables with indexes out the wahzoo and joins all over the place but I have designed the tables and wrote all the code to manipulate them. I had to look stuff up on Google to find out the limitations of SQList and its syntax heck I even had to look up some very basic syntax. I have used ADB on the Android side to verify my table columns and rows. None of it is rocket science and really this is some of the easiest code to write. Doing multi-threaded GUI programming is much tougher.

On the IDE side I enjoy IntelliJ. Past experience had it running too slow but that is not the case today on the faster hardware and improvements they have made. I have written a plug-in for IntelliJ to verify MigLayout code. I use the Eclipse key mapping so I can switch between the two with ease.

I now have Eclipse set up to work nicely with the Android SDK. You can do Android work with IntelliJ too but I find Eclipse to be the IDE of choice on that side of the house. Mainly because Google does the plug-in for Eclipse and keeps it up to date. I am using 3.6 with the Android source installed so I don't have the code assist slow down issue any more. I have a Samsung Galaxy S phone and I use three flavors of the emulator - 1.6 lower dpi, 2.3 matching my phone dpi and Samsung Tablet. Seems to let me test things and solve any "fragmentation" issues. I also have the emulator set up for the BA I work with and the QA team.

For the Mac I have a Mac mini running a 20" screen. I only have one iTouch authorized to run code and QA has that most of the time. You can look other my other posts to see the fun I am having trying to get another device provisioned. They are going to buy me a MacBook Pro soon so I can do more Mac experimentation at home. I recently upgraded to Xcode 4.0 which is much nicer than the 3.x series. Still my least favorite IDE but I am getting better at it. It just seems a few years behind both IntelliJ and Eclipse. Part of the issue is Objective C - it is C based making it harder to write an IDE. You can even see this on the PC side, it is more difficult to refactor C and C++ code than it is for Java code. The rest is Apple being the only IDE game in town. If there were competition in this area on the Mac I am sure things would improve.

I will get into a groove on all the areas listed in due time. Right now on Friday's I come home mentally fried. On the main Java app I am pretty sure of what I am doing. JIDE has very nice controls. I have used MigLayout in the past and prefer it over any of the Java layouts. The rest of the coding is pretty straight forward.

Android is going nicely but there are some speed bumps. I find answers pretty quickly on-line. The official Android docs could use more examples but have solid content. I can almost always find sample code on Stack Overflow. The API is well laid out and method names make sense. I know Eclipse so moving around in the IDE is second nature. I can put the app on any phone with ease, people walk buy, I plug it in, press run and it is on their phone. Love that.

The iOS side gives me the best and worst feelings. I feel a real sense of accomplishment when I get something to work because it is a more difficult to do for me on that platform. The worst is that I am never sure if what I did was the right thing. Did I release the memory properly? Did I use the right API calls? Did I write code where there was an existing API call I could have used? Some of the calls see so crazy, such a trimming a string, that I feel there has to be a better way but usually there is not. You get to the point of diminishing returns trying to look up better ways of doing things.

Having a Mac available at home is going to be a big help. I can experiment with the OS, install some tools that will make things easier, learn the keyboard shortcuts and play around in Xcode giving me a chance to experiment with one off projects just like I do on the Android.

The job switch has been worth it. I feel a weight lifted off my shoulders from fighting the management. Now I am fighting technical challenges but that is OK. That is something you can beat over time. Electrons don't harbor crazy thoughts and follow illogical rules. Get it working, get it shipped and get started on the next version. Working with sane people is so nice.

Wednesday, February 16, 2011

iPhone provisioning

We want to set up another QA device as the only actual device I have tested our app on is an iTouch. A QA staff member has an iPhone and is willing to have me install the application on his phone. This should be easy but it is not. In fact it still is not working.

First I had to have my boss log in to our iOS developer account and provision the identifier off his phone. Easy enough. Then I fire up Xcode 4 and click all over the place in organizer and finally get it to recognize the phone then it does some rather long communications with it before it settles down. I then attempt to build and put the app on the phone. No dice. It does not like something about the phone and keys and profiles. I fiddle around with it for a bit and look up what I can on Google. Still don't have it working but I needed to be done so he could get back to work.

I will do some more looking around on Google to see what I can find. Sounds like this is a very common problem and people just clean / build / clean / clear / clean / build until it finally works. No one so far has had a nice solid solution.

It took us a month to get anything working with our iOS account as it was. Apple had to cancel the whole thing and recreate it at one point. This has been nothing but a huge PITA. I am very underwhelmed with the whole iOS developer experience as far as hardware goes. They generally treat you like a crook and you just feel lucky if you can get any of it too work and once you do you don't know how you got it to work and you just hope you never have to touch it again.

I need to provision a few more devices so I hope I can get this one working and I can learn enough to apply the knowledge to the next set. This is really just stupid and you should not fight your developers tooth and nail and every turn. Let me put my code on whatever device I choose!

Really a total opposite to my Android experience. A support person got a new phone last night and asked for the latest build to be put on it. I walked it over to my desk, plugged in my USB cable, did a Run in Eclipse, selected her phone from the list of devices and it was installed. Less than 1 minute passed and I turned it back over to her. I have installed it on 5 different phones in the office doing the same procedure. With one I had to install some USB drivers first adding a few minutes to my time. Otherwise it has been dead simple. My app being installed on any phone I like. Simple.