I'm one of the people that felt that having a preprocessor in Java is
fine. I actually fine with any tool that helps you just get something
done. Also just for the record Sun added support for a preprocessor in
NetBeans and C# has support for a kind of conditional compile.
First you should try and use interfaces along with factory methods to
handle the broad strokes and areas that don't require crazy
performance. I have an interface for stuff like GraphicsDevice,
AudioDevice, NetDevice etc and have an App class that creates the
devices based on some properties that get set when the App is created.
So you still need some method to tell your App which interfaces to
create. Below is a simple example of how it can be done.
I just typed this out so I don't know if it even compiles. The idea is
that you make an eclipse project for each configuration you want and a
class that sets the static variables. The projects use linked sources
and filters to include/exclude the correct files.
class MyAppBase
{
static boolean LITE_VERSION = true;
public void doSomething()
{
if ( LITE_VERSION == false )
{
// add something that only the full version has
}
}
}
class MyLiteApp extends MyAppBase
{
public static void main( String[] args )
{
LITE_VERSION = true;
new MyLiteApp();
}
}
class MyFullApp extends MyAppBase
{
public static void main( String[] args )
{
LITE_VERSION = false;
new MyFullApp();
}
}
Using this method can create an explosion of projects but I don't make a
project for EVERY case. I generally make projects for LITE, RELEASE and
DEV. The DEV version is what I use to develop with daily and I change
the configurations without a concern. The LITE and RELEASE tend not to
change much.
Now, with all that said I still use preprocessing. I use it for the
cases that require performance such as an inner loop or if refactoring
the code is way too much work for the gains. For this I use Antenna and
I ONLY use it for a deployment build. The deployment build doesn't use
eclipse at all and is just an ant script. IMHO the only way to deploy
is using ant. I also use some regular expressions to handle changing
package names.
http://antenna.sourceforge.net/
Antenna will allow you to do the following:
//#ifndef RELEASE
System.out.print( "Debug" );
//#endif
On 19/12/2011 4:51 PM, topazmax wrote:
here we go again...
Because there are more advanced features that give you greater
control,
please just point me in that direction.... please please please....
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en