I suggest steering well clear of preprocessors.
There are publishers whose coding standards explicitly prohibit the use of them, and for good reason too.
You have a publisher for J2ME games?
Or do you mean Java-Verified?
In my personal experience preprocessed code becomes unmaintainable in a very short space of time,
Unless the person knows what they are doing, definetly not so.
While there are problems in the j2me landscape they will be there no matter what system you use.
F.i. my comp supports 60+ device groups ... I'd hate to imagine how it would be without a precompiler.
Not to mention the size, as using a precompiler will simply remove code so it is never passed to the compiler.
Trivial examples such as :-
1. can you 'define' stuff with antenna or use includes?
2. using 'features' is a sure path to getting yourself into a LOT of problems.
Already begin to show the problem of preprocessors.
For example, apply the above example to the area of Sound playback.
You will need different code for :-
- Nokia midp1,
- Nokia midp2, (with subtle but critical differences between 6600, 7650, 6230i, and a host of others)
- Samsung, (both using the Samsung API, and using midp2. Again, both implementations will require subtle differences for various devices)
- Motorola, (several different variants would be required)
- SonyEricsson, (atleast 2 variants would be required)
The list goes on and on!
Same problems you have with or without preprocessors.
And this is covering just the single aspect of sound playback!
Move onto any of the other areas that require changes when porting a game,
or address API bugs that appear on a per-device (or even per-firmware) basis
and the numbers of preprocessor statements balloons enormously.
Once the system is setup porting is quite easy.
I have seen games where there are more lines of preprocessor statements than lines of game code!!
At this stage, the code might as well be junked, as it has no value what-so-ever.
And I have seem games that were so horribly bloated it is a wonder they actually got the game in the jar!
The problem often lies with the programmers and not with the tools.
Anyone can write horrible code! But we do not blame Java for it do we?
Basically, preprocessors are not scalable. They appear to be an adequate solution when you have to worry about just ~3 tiers of device -
but when the reality appears that you need to support upward of 100 devices, preprocessors are completely useless.
You simply need to do some software engineering. Preprocessors are very flexible and powerfull.
Again, programmers are mostly at fault. I know my share of people that take the easy way and do exactly as you say. It is missleading to blame the tool for the user screwing up!
I know other companies that have other interresting ways of porting.
They copy the project and then change what needs to be changed.
So for every game they have, in case of 100 devices, 100 different versions!
I wish I could elaborate on the alternative, but I would be in breach of my contract and would almost certainly get fired
Hehe same here.