Home > Java Killers > Java Killers #001 – Public Enemy

Java Killers #001 – Public Enemy

Post moved to http://www.paulszulc.com/2009/java-killers-1-–-public-enemy/

Categories: Java Killers Tags: ,
  1. June 5, 2009 at 7:55 am

    I gave correct answer! What did I win? 😉

    • paulszulc
      June 5, 2009 at 8:09 am

      Roadtrip to Wroclaw 🙂

  2. Shooter
    June 9, 2009 at 9:23 am

    I have to say that it is not the public modiefier’s fault. You can use private as well. All of the confusing situation is connected with getter method – the lack of it. As everyone knows instance variables haven’t polymorphic behaviour. Only instance methods can be polymorphically invoked. If you used getter instead of f.a everything would be OK.

    • paulszulc
      July 9, 2009 at 7:48 am

      @Shooter: you are right, private would be a problem as well, but as a field being public, it can be accessed by simply doing Foo.a.

      So being public is somewhat one of the issues here. Encapsulation is simply always good idea. Nevertheless naming fields with names already taken in super class can very quickly lead to problems and all good IDEs will tell you so 🙂

  3. Shooter
    June 13, 2009 at 3:12 pm

    Noone’s going to reply and discuss?

    • July 5, 2009 at 9:50 pm

      Maybe there’s nothing more to say? 😉

      When I first got to know about it I was surprised that variables are not virtual. I’m wondering – why?

      • paulszulc
        July 9, 2009 at 7:49 am

        Did you ever find it in JLS?

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: