Using Imports to Change Behaviour
by, 11-29-2011 at 03:24 AM (1007 Views)
One thing that would be great to have is a feature that I know well from my previous experience coding in C. That is the possibility to conditional compile in order to modify the behaviour of the application. A feature that is missing from Java is Cís conditional compilation, which allows you to change a switch and get different behaviour without changing any other code. I think is was left out of Java is that I remember using this feature often to address issues related to compiling a program on different platforms. As java was built to be cross-platform, I guess they deemed such a feature to be unnecessary.
There are still other valuable uses for conditional compilation such as for debugging. It would be very straightforward to be able to enable features for debugging during development and disable them for a production. Now I discovered that a way to move from debug to production versions of a package is to change the package being imported. This is a technique that I use quite often when going from simulated to real versions of packages with which I need to integrate.