«« Next » « Previous
«« Next » « Previous

Link Details

The more, the merrier! Login and vote now.
Link 66759 thumbnail

By HamletDRC
via gbracha.blogspot.com
Published: Feb 18 2008 / 16:09

Gilad Bracha, co-Author of the Java Language Specification enumerates the reasons why we should never use the static keyword in Java code. Excellent and short.
  • 24
  • 8
  • 2405
  • 770

Comments

Add your comment
User 161244 avatar

hohonuuli replied ago:

0 votes Vote down Vote up Reply

What a load of hooey.

User 107114 avatar

daniel replied ago:

1 votes Vote down Vote up Reply

Quite correct. Unfortunately, imperative languages without platform-level support for singletons will constantly find themselves encouraging the use of static. Obviously it should be minimized, but no one ever seems to be able to get rid of it entirely. This is part of why Scala is so awesome: it gives you all the benefits of static without the rampant downsides. In fact, it makes it easy to avoid statics altogether (by relying more on local, immutable state).

Will static disappear eventually? Oh yeah. But I doubt that it's going anywhere any time soon.

User 209827 avatar

evarlast replied ago:

0 votes Vote down Vote up Reply

@daniel I don't see why it cannot be eliminated completely. IoC containers like Spring or Guice take service location trump it with using the container.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.