A concrete example from the OP would help. I can think of cases where conditional compilation (as done in C/C++) is and is not needed in Java.
On Apr 1, 2010 9:28 AM, "Bob Kerns" <[email protected]> wrote: My first response was to say "OF COURSE YOU CAN!" -- but then I realized you must be talking about including or excluding data members, rather than the actual data. All I can say is, if you're doing that in C++, you're doing it wrong, and you should read up on object-oriented design patterns. C++ goes out of its way to make #ifdef unnecessary. But a lot of C++ programmers come from a C background, or read a lot of C in the process of learning C++, that they never learn to properly use it. It doesn't help that the language is insanely complicated, and it takes a LOT of time and effort to become really proficient. Adding or not adding fields and methods to classes should be handled through subclassing and/or interfaces. And you should consider refactoring into collaborations of separate objects, rather than large flat classes. Guy Steele, the author of the Java standard, cowrote a popular book on C, and was a key member of Tartan Laboratories, which created optimizing C compilers for a wide range of platforms. James Gossling had a huge amount of C experience as well, implementing Gossling Emacs, and of course, Java. Hell, Guy used to write maintain a huge amount of ITS PDP-10 macro assembler, code that I also worked on as part of the same group at MIT, so I can say with absolute certainty -- the designers of the Java language and its standard are VERY aware of conditional compilation, and the reasons it is not in the language are to make it a better language. I can also speak from my own personal experience. It's hard to quantify my C/C++ experience, but it goes back to the 1970's, long before there was even a dream of C++, and Java since relatively soon after it came out in 1995. I've mentored a lot of people both in C++ and Java. I've also participated in language standardization efforts, maintained and written compilers and language runtimes. Now, all that constitutes "argument by authority", and proves nothing, of course. But I'm not trying to get you to switch off your mind and just believe what I'm telling you. On the contrary -- when there's a consensus of experts, you should poke around, kick the tires, explore, try things, look for counter-examples, etc. One of the best type of counter-example is "X is a real gain of time", as you put it. My guess is that it's a gain of time for you because you're not familiar with other techniques, but if you'd like to post a more concrete example, we can discuss it and alternatives. I won't waste your time with examples of how conditional compilation can waste your time, as the solution is generally "don't use it that way". But I'm generally in favor of things that save you time. Sometimes, even things that save you time up front but cost you more time later. On Mar 31, 4:50 pm, Emmanuel <[email protected]> wrote: > Waooo... > > I think you are a li... > Emmanuelhttp://androidblogger.blogspot.com/http://www.alocaly.com/ > > On Mar 30, 12:36 pm, Bob Kerns <[email protected]> wrote: > > > > > You do not do that in Java. > > >... -- 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 To unsubscribe, reply using "remove me" as the subject.

