Introduction The Graduate is undoubtedly one if the best movies of all time, but what does it have to do with mobile application user interface development?It would be a waste to spend a great deal of time designing and tuning your application's processing algorithms and its data-access and memory models but neglect to pay sufficient attention to the code that interacts directly with the operating system to provide the user experience. This chapter is about getting the right user interface development plan together, one that ensures that the user's mobile device experience is a crisp and visually pleasurable one. You need a definite plan.The most visible aspect of an application's performance is its user interface. How quickly the application responds to user commands and the speed with which repetitive drawing tasks are done has an enormous effect on the perception of the quality of your application. Sluggish performance, user interface flicker, and any stalls that occur during what the user expects to be smooth operations will result in a negative assessment of the quality of your application. Because mobile devices are often held and operated in people's hands and used like mechanical tools, there is an even greater expectation of responsiveness than with desktop computers; a pocket watch does not have flicker or periodic states of unresponsiveness nor does a street map or a pocket notepad. Many developers have needlessly mired their application in bad user interface performance; an application that appears sluggish is simply not a good application. Good user interface performance on mobile devices is achievable but is a matter of meticulous attention to detail. What is needed is a strategy for ensuring that the right problems are addressed so that the result is a responsive user interface and good user experience.Mobile device applications pose a seeming paradox to performance-minded developers. On one hand, end users expect a device that is operated while being held in their hand to behave like a physical gadget and give immediate responses to their actions. On the other hand, mobile devices have fewer computational resources than their desktop brethren with which to generate the desired effect of immediate response. The seeming paradox of higher expectations and lower processing power is resolved by the fact that the user interface devices present are smaller than desktop computers and that the devices themselves are typically running fewer processes in parallel than today's desktop computers. Excellent performance and responsiveness are indeed possible for mobile applications. Nevertheless, well-considered approaches to designing user interface algorithms are important to ensure a highly responsive experience for users.As with memory management and other aspects of performance, good engineering practices for mobile software design are not unique to mobile devices. Learning to design and write great-performing mobile device user interface code will make your desktop applications perform significantly better as well. Desktop environments today are so powerful that many developers simply ignore thinking about performance when designing their user interfaces. This results in unnecessarily sluggish user interface behavior. Comparing a user interface that was designed with performance as a top-level goal with a user interface where performance was a secondary or tertiary consideration will immediately show you the difference between the two approaches. The first application looks and feels fast and has no flicker when things update, no random pauses, and no overall sluggishness; it feels like a sleek machine. The second application feels a bit sluggish; it probably has some flicker as controls such as list boxes are updated, and occasionally stutters; it is like a car in general need of a tune-up. Even if the underlying functionality is identical, a user interface's responsiveness and the visual smoothness of an application has a great effect on the perception of its quality. This is true for desktops and doubly true for mobile devices. Compare two mobile phones, one with crisp behavior and one that is a bit sluggish and you will immediately notice the difference. Regardless of the features and underlying quality of the applications, the snappy-performing phone will feel more solid and reliable.Writing user interfaces that perform well can be broken into three areas of consideration:Design strategies for writing user interface code that performs. Most modern programming frameworks have higher-level abstractions for driving the user interface. A framework manages windows and dialogs as well as the controls that live inside them. The developer writes code that responds to events generated by the user interacting with these user interface elements. Because of the higher-level abstractions used, it is easy to forget that each programmatic action requested of the user interface has a potentially significant cost. There are often good ways and bad ways to write this code. Optimizing the design of this high-level code is important to make user interfaces run with "snappy" performance.Design strategies for writing graphics code that performs. Whereas user interface code works with higher-level abstractions such as controls and windows, graphics code works with bitmaps and lower-level rendering abstractions. Graphics code is the code that does the low-level drawing and image manipulation. Graphics code often performs lots of small actions inside a loop or is called by event handling code to paint or repaint pictures that are used by higher-level user interface code. Whether you are doing page-flipping animation for a game, drawing bar charts for a business application, or writing the rendering code for a custom control, there are important ways to maximize your graphics throughput.Choosing appropriate bitmap formats and sizes. Both high-level user interface code as well as lower-level graphics code often work with images. Many formats and usage choices exist for this data, each optimized for a different purpose. Choosing the right image strategy for your needs will give you the right size and performance balance.
|