Friday, November 13, 2009

Engineering Achievements and Challenges

The National Academy of Engineering (NAE) put together two lists: one that ranks the 20 greatest engineering achievements of the 20th century, and one with engineering's challenges to be accomplished:


SOURCE: IEEE Spectrum

Thursday, November 12, 2009

Android Sliding Puzzle

Yesterday I released my first Android application into the Android Market. The application is a sliding puzzle game, and comes into two flavors, a free (lite) version (called "Sliding Puzzle Lite"), and a full version ("Sliding Puzzle Full") at $0.99. The lite version has only the basic features, such as 9 pre-loaded images and the ability to view the full (final) image during game play. The full version has the following features:
  • pre-loaded with 9 images
  • 4 difficulty levels (3x3, 4x4, 5x5, 6x6)
  • shuffle puzzle image
  • view final image
  • load image from SD Card
  • take a picture using the Camera and load it as a puzzle
  • displays a timer during game play 
  • displays how much percentage of the puzzle is done
  • displays the number of moves made
Below are some screen shots of the application:



I want to make some observations about the entire process.

First, the design was far from optimum in the first iteration; it was too complex for a one-screen game (one main screen, namely the puzzle screen). I started refactoring when I had to add some features and I noticed how hard it was to do just that. I ended up getting rid of some classes, methods, and instance variables all together, simplifying the design. Efficiency is crucial when developing for mobile devices. My background is in Java ME, where the restrictions are even bigger than on Android-based smartphones. For example, because I had to work with key-value pairs, instinctively I first went with a HashMap. I notice that the key-value pairs where actually pairs of integers, so I switched to using a SparseIntArray, which is more efficient that a HashMap. An even better approach would have been to use to parallel arrays of ints, but that's exactly how the SparseIntArray class is implemented, thank you for that! Overall, I tried to follow the guidelines form Designing for Performance document. Hence, the entire process was an iterative/incremental one, based on add feature <=> test feature <=> fix bugs <=> refactor (I hope the model does not look like a waterfall one because it wasn't :)). I noticed that testing and fixing bugs took the most time (and I am sure I still have bugs left unnoticed by me). I have been testing for the past month (and I've been doing all this in my spare time, being that I am working on my PhD also). Testing was still done manually (I hate that I do not use some kind of unit testing in Android). My biggest problem was that I was getting out of memory exceptions when loading bitmaps (especially when loading from SD card). I ended up using Bitmap.createScaledBitmap method to scale the bitmaps down. Furthermore, having the bitmaps displayed on the screen was initially done in a 'bulk' manner, where the screen would freeze until the first couple of images could be displayed. That's not user friendly at all; reading some blogs from smarter people, I ended up using a AsyncTask, where each image I would load, I would display on the screen, one at a time. With that, you would images being loaded on the display, similar to how the Gallery application (that comes pre-loaded on the phone) works.

Second, nothing beats testing on a real device. Emulators do come close, but having a device made quite a difference. For example, on some G1 phones, the camera software has a known bug, namely that the camera preview does not work in portrait mode. This issue is of course non-existent in the emulator.

I keep telling fellow students that I work with (or teach to), that nothing beats writing applications. Sure, you can read books (which of course you have to do), run examples, but if you do not start coding, you will never get to the next level as a programmer.

There are other lessons I have learned, and maybe I will post them in a later post.

Overall, I am looking forward to adding new features to the full version of the game (such as speech recognition, integration with Facebook, and many more), and also developing the next game from the list of ideas that I have.

I hope you enjoy the sliding puzzle, at least as much as I enjoyed developing it!

Saturday, November 7, 2009

Saturday, October 31, 2009

Beyond BigTable - Spanner

BigTable is a distributed storage system designed to work in very large distributed systems where you have petabytes of data on thousands of servers. It is currently used in over 100 projects such as Google Earth, Google Maps, Blogger, Orkut, and many more.

However, there is some current work at Google on a new storage and computation system called Spanner. Some of its main characteristics:
  • Automation: moves and replicates data based on usage and constraints patterns.
  • Use of hierarchical directories (instead of rows as it is in BigTable).
  • Support of distributed transactions
  • Fine grained access control on the data
  • String consistency across tablet replicas
  • Scale to 10M machines and 1k petabytes of data, across 1000s of locations
There is a keynote talk by Jeff Dean of Google on "Design, Lessons and Advice from Building Large Distributed Systems" that talks about large distributed systems and includes topics on BigTable and Spanner. You can view the slides of the presentation here.

Wednesday, October 21, 2009

Current and upcoming Android Phones

WiseAndroid has gathered a list of 50+ Android Phones that are currently on the market or will become available in the near future. TechCrunch provides images for (some of) the phones. Thank you for the effort!

Thursday, October 15, 2009

Performance Comparison of Major Web Browsers

Six Revisions has published a performance comparison of the major five web browsers (Firefox, Chrome, IE, Opera, and Safari) in terms of JavaScript speed, CPU usage under stress, DOM selection, CSS rendering speed, page load time, and browser cache performance. Bottom line, Google Chrome 3.0 wins in four out of the six performance indicators, coming third and second in the DOM Selection Speed (won by Opera) and Page Load Time (won by Firefox) tests.