Search:
|
Access:
» Debugging J2ME-based Mobile ApplicationsRelated categories: Java | Object-oriented Technics Adam SzareckiViewed: 9179 | Article date: 2006-05-11 15:18:22 Surprisingly enough, debugging applications written using the Java J2ME technology is a very problematic task. Most programmers use various emulators for that purpose, which reproduces physical devices in software; then again, this approximation is often far from perfect. When one comes across a problem which cannot be reproduced using an emulator, it presents a major technical problem. This article presents two possible solutions to this problem.
Surprisingly enough, debugging applications written using the Java J2ME technology is a very problematic task. Most programmers use various emulators for that purpose, which reproduces physical devices in software; then again, this approximation is often far from perfect. When one comes across a problem which cannot be reproduced using an emulator, it presents a major technical problem. About the authorAdam Szarecki is an alumnus of the Faculty of Computer Science and Management of Poznañ University of Technology, presently employed at a senior programmer at the company M-navigation. The solutions presented here have come from NaviExpert – a GPS navigation system for mobile phones developed by the company. Contact: aszarecki@m-navigation.pl The vast majority of mobile devices, especially mobile phones not based on the Symbian operating system, doesn't allow direct access to standard output streams System.out and System.err, commonly referred to as "the console", which we could use to watch messages produced by our applications. This article presents two possible solutions to this problem. ArchitectureLet us begin by defining a superclass called Log, which will be used to broadcast messages. Depending on its configuration, it will be possible to send those messages to standard output or redirect them to an arbitrary destination for storage or presentation in a different form. Our architecture will take advantage of polymorphism, isolating the logic of filtering and formatting messages (placed in the superclass) from their physical storage or presentation (which will be implemented in subclasses). In order for the logging to be easy to use and save memory, public methods used for logging are static. They redirect method calls to a single instance of one of the subclasses of Log (the software patterns of: delegation and singleton objects). Listing 1. Source code of the class Log.java
package com.naviexpert.util; One of the advantages of this solution is sane size of final code, encompassing only classes which really are used in the application (automatic removal of classes without references from code is referred to by the term obfuscation). Listing 2. Source code of the class LogServerListener.java – a server receiving logging messages
package com.naviexpert.util;
|
|
Copyright C 2006 by Software Developer's Journal. All rights reserved.





SDJ Users:
Shopping Cart









