This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Introduce API for answer to Life, Universe and Everything In a couple of places in the IDE a value (any value) is needed, and some developers seem to prefer the number 42. Among others: core.output2/test/unit/src/org/netbeans/core/output2/WrappedTextViewTest.java core.startup/test/unit/src/org/netbeans/core/startup/jars/library-src/pkg/subpkg/Something.java java.api.common/src/org/netbeans/modules/java/api/common/classpath/ClassPathSupport.java In order to minimize usage of magic numbers and encourage other people to use this value, I propose to introduce an API for it. Since I believe this change is simple and uncontroversial, I want to shorten the review process a bit and commit later today.
Created attachment 59475 [details] Proposed change
Please review.
looks good.
Well crafted API.
seems reasonable. Please, please, only for trunk. The upcoming NB 6.1 is bug fixing release therefore it definitelly doesn't need sofisticated features as this one.
PH01: It is suspicious that the ANSWER_TO_LIFE_UNIVERSE_AND_EVERYTHING is rational (number). PH02: apichanges.xml - Change introduces new field so description is probably wrong ("returns the answer").
Re PH01: we must be compatible with the standard. And it seems the author of the standard has specifically ruled out non-integers: http://en.wikipedia.org/wiki/Answer_to_Life%2C_the_Universe%2C_and_Everything Re PH02: OK, I will attach an updated diff to explain it better.
Created attachment 59481 [details] Proposed change (update 1)
TN01: what is the level of stability of this API? TN01: an advise - it is always good to use a new API immediately after it is introduced to make sure that it suits its usecases...
Re TN01: excellent question. The number 42 is a third-party API, and general wisdom teaches that you should not allow third-party APIs to leak into your API. However, since the value took such a long time to compute, I hope we can consider it stable. Therefore, I propose to make in an official API. In the unlikely event that the value should change in the future, we can always introduce Utilities.ANSWER_TO_LIFE_UNIVERSE_AND_EVERYTHING_2 to satisfy the backward compatibility requirements. Re TN02: you are right. I will attach a diff with changes in the mentioned files. I discovered that the number 42 is also used in the java.refactoring, albeit multiplied by a constant, so that usage should be modified too.
Created attachment 59486 [details] Usages of the proposed change
Looks great but [JG01] Please verify that you do not block EQ for 2.3667714e+17 msec (or more, on slower hardware) computing the answer.
[RB01]: Can we get API also for recomputing the answer, just in case Sustaining team would need to maintain it?
Yff Missing @since tag Yfe As always, I am not glad that a new API pollutes already pretty polluted openide.util. Can't you create a new module for this new addition?
I would think twice about making ANSWER_TO_LIFE_UNIVERSE_AND_EVERYTHING public.
Re JG01: sure. I used the value as precomputed by the author of the standard. I hope the author got it right, since I didn't have a Deep Thought to check. Re RB01: definitely. I would need you to provide a Deep Thought and make sure JDK 7 is ported to it.
Re Yff: how could I forget that? I will attach an updated version Re Yfe: well, having a special module for the answer to Life, Universe and Everything is a very appealing idea. However, I am afraid that such a solution would hinder the adoption of the API. Users would not know about the new module and would reinvent or copy-paste (flawed) algorithms to compute the value, which, as Jesse pointed out, could impact the performance of the IDE. Or they would just use the value directly, which is wrong (usages of magic numbers are discouraged). I therefore believe that the API can only benefit from being in such a prominent module.
VS01: I think that we should consider creating a pluggable SPI for this to support Netbeans platform users from different Universes where the answer could be different.
Gents, that's really great idea... I'm building plug-in for CRM system and it would be really useful to be able to check if life, universe and everything is still stable and ok when exception and/or unpredicted input happens. It would be ideal to have this API available in Java so I would be able to call this check prior to all methods. Stability of the system is crucial to us and this could be nice solid base...
Thank you all for your valuable comments. Integrated in changeset 000001042008.
Thanks! Everything is much clearer now.
verified in M1. IDE is now much more life friendly than I've ever expected. Just my .42 $