Best practices: The challenge of designing software for wireless devices
5 min read
5 min read
Designing good software for wireless devices such as mobile phones is not straightforward. Developers have to consider and address the device's constraints such as memory, processing power, input, screen etc.. but also the environment such as wireless network constraints.
I found an interesting sun article that gives some suggestions on wireless software design. For instance it suggests to pose the following questions when developing wireless applications:Moreover the article provides some guidelines which I find quite useful to take a look at:
- What impact do devices with limited resources have on application design?
- How important is it to develop applications that are platform-independent?
- What security issues should I be aware of?
These guidelines follows a section called "performance-driven programming", giving the following suggestions:
- Environment. Do some research up front. You must first understand the needs of your potential users and the requirements imposed by all networks and systems your application will rely on.
- Architecture. The architecture of your application is very important. No optimization techniques will make up for an ill-considered architecture. Your two most important design goals should be to minimize the amount of data transmitted over the wireless link, and to anticipate errors and handle them intelligently.
- Application partitioning. You need to think carefully when deciding which operations should be performed on the server and which on the wireless device. MIDlets allow you to locate much of an application's functionality on the device; it can retrieve data from the server efficiently, then perform calculations and display information locally. This approach can dramatically reduce costly interaction over the wireless link, but it is feasible only if the device can handle the processing your application needs to perform.
- Data representation. Data can be represented in many forms, some more compact than others. You should consider available representations and select the one that requires fewer bits to be transmitted. For example, numbers will usually be much more compact if transmitted in binary forms rather than string representations.
- Message latency. In some applications, it may be possible to do other work while a message is being processed. If the delay is appreciable -- and especially if the information is likely to go stale -- it is important to keep the user informed of progress. Design the user interface of your applications to handle message latency appropriately.
- Interface simplicity. Keep the application's interface simple enough that the user seldom needs to refer to a user manual to perform a task:
- Reduce the amount of information displayed on the device.
- Make input sequences concise so the user can accomplish tasks with the minimum number of button clicks.
- Offer the user selection lists.
for(int i=0; i< obj.length; i++) {...where the length of the array is evaluated every time the loop iterates, it is more efficient to define a local variable and call the accessor only once:
// do something with array elements
}
int len = obj.length;
for(int i=0; i<len; i++) {
// do something with array elements
}
int len = record.length;... creates and destroys a new instance of
try {
for(int i=0; i<len; i++) {
MyObject obj = new MyObject();
// do something with obj
}
} catch(Exception e) {
e.printStackTrace();
}
MyObject
every time the loop iterates. You can avoid this object
churning -- continually creating and discarding objects in the memory heap -- by moving the object creation
outside the loop. A more efficient way to rewrite the code above would be to create the object outside the try
statement and reuse that object as follows: int len = record.length;By reusing a single object instead of creating many the program uses
MyObject obj = new MyObject();
try {
for(int i=0; i<len; i++) {
// do something with obj
}
} catch(Exception e) {
e.printStackTrace();
}
+
operator causes object
creation and subsequent garbage collection, and thus chews up both memory and processor time. It is more efficient
to use StringBuffer.