Having headache developing for mobile?
Being a mobile developer might be considered ‘cool’ especially when the final product is ready, but what goes through a developer’s mind before and during development is usually mind boggling. Designing mobile apps using J2ME for Symbian phones can be a bit tricky due to the target phones’ specifications. Most of these mobile devices don’t have large overall and peak memory, hence, If you try to apply all the cool practices learned to be very good with Java will result in a huge Java Archive or Java Application Descriptor (JAR/JAD) files. Object Oriented practices need a complex class representation and this is not possible when working with 64-100 kilobytes software. Also the effort needed to manage classes is pretty big and many Java Virtual Machine implementation will finish all the resources too quickly.
Developing applications for small devices requires you to keep certain strategies in mind during the design phase. It is best to strategically design an application for a small device before you begin coding. Correcting the code because you failed to consider all of the “gotchas” before developing the application can be a painful process for example when u find out that applications have a class limit of 64k as I did!
Knowing some tips of best coding practice in general helps you keep your software reusable and easy to expand and fix.
Here are a few tips to consider before settling down to coding your app;
- Keep it simple. Remove unnecessary features, possibly making those features a separate, secondary application.
- The smaller in size the app is the better. This should be a ‘no-brainer’ for developers. Smaller applications use less memory on the device and require shorter installation times. Consider packaging your Java applications as compressed (jar/jad) files.
- Minimize run-time memory use. To do this, use scalar types in place of object types. Also, do not depend on the garbage collector. You should manage the memory efficiently yourself by setting object references to null when you are finished with them.
You can reduce run-time memory also by using lazy instantiation, only allocating objects on an as-needed basis. Other ways of reducing overall and peak memory use on small devices are to release resources quickly, reuse objects, and avoid exceptions.
- Avoid using many components or images that will render your application heavy. If possible, do image compression.
- Ensure that you have the correct API platform selection depending on the level of the device you are developing for. Some limitations in different MIDP’s (mobile interface development profile) may be avoided by using a vendor-specific API or MIDP 2.0, but which obviously reduces the portability of the application.
- Versioning and documenting your code well. I need not say anything about this.
The post continues….. “Developing for Mobile with the aim of achieving the best performance”