The number of classes does however impact on the memory footprint
What do you meen? Can you explain in more details? Is there any difference for the Mobile
device between 1 class of 10 kb or two classes, 5kb each?
yes, each Class definition has a memory footprint. The actual value is dependant upon JVM implementation and class file structure, however it is typically in the region of a few hundred bytes.
Object instanciation is what has a speed impact.
The optimal number of classes is 2.
If there is no speed difference I see no reason to put all the code in one class (that extends canvas,
because the one that extends MIDlet does almost nothing untrivial).
I don't understand what you mean by "MIDlet does almost nothing untrivial".
However, I completely concur, placing all your code in a tiny set of classes is just plain ridiculous - your code will become completely unmanagable.
There are techniques and technologies to maintain the modularity of classes, while still gaining the benefits of having a small number of classes.
Many people use preprocessors, and while this approach will serve you ok for a time - you will eventually require a more advanced approach as preprocessors seriously inhibit debuggers and IDEs like Eclipse.
The more advanced solution is to perform class heirarchy transformation.
Several tools already exist to perform this task, 2 freely available ones are JAX and JOGA.
I can say no more.