Wednesday, October 8, 2008

Fewer classes

Each class definition creates a corresponding class file, even nested classes. The fewer classes you have the smaller your jar file will be. A Java ME application may have only one class, the MIDlet, and this single class can implement CommandListener and be responsible for all application GUI.
If you are developing a game or an application with custom user interface, you will need another class that extends Canvas, but this is the bare minimum.
Having all your application code in one or two classes is not Object Oriented programming. It is not easy to develop like this if you use a simple text editor, but it can be done with current IDEs like Eclipse or NetBeans.
Keep in mind that, for achieving small jar files, you will need to use development techniques not related to OO.

No comments: