• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help Me!! Conditional compilation in Java  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Im a programmer migrating from C to Java. One major drawback (or is it?)
I see in Java is the lack of support for conditional compilation (the #ifdef sort of stuff).
Code maintenance for multiple client requirements becomes very clumsy without support for conditional compilation.
Is there any workaround that any of you could suggest or is Java having any plans of supporting "conditional compilation" anytime in near future?
Anticipating an early reply,
Karthik
 
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Karthikeyan Muthukumarasamy:
Hi,
Im a programmer migrating from C to Java.

Cool! Are you aware of http://developer.java.sun.com/developer/Books/shiftintojava/page1.html ?

One major drawback (or is it?)
I see in Java is the lack of support for conditional compilation (the #ifdef sort of stuff).
Code maintenance for multiple client requirements becomes very clumsy without support for conditional compilation.
Is there any workaround that any of you could suggest or is Java having any plans of supporting "conditional compilation" anytime in near future?

The best "workaround" is to make use of polymorphism. Take a look at the Strategy pattern for a very basic example. You could also provide an example of a conditional compilation and we'd explore a good implementation in Java.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!