>Newbie Java/OOP question here, which is more correct?
>
[quoted text clipped - 13 lines]
>I prefer to make it public, less typing all around, but being my luck,
>it isn't the correct way either :)
Correct is what you make of it...
But.. Generally, using accessors and mutators (get/set methods) is
considered more OO. For instance, you might want to make an instance
variable readonly, so just use a get method. YMMV.
Plus, as for typing, any decent Java IDE should generate the get/set
methods for you.
--
now with more cowbell
Brian Munroe - 29 Mar 2005 21:01 GMT
> For instance, you might want to make an instance
> variable readonly, so just use a get method. YMMV.
I knew there was a reason why it was better, I just couldn't think of
one!
> Plus, as for typing, any decent Java IDE should generate the get/set
> methods for you.
I just tried this in Eclipse, neat!
thanks
-- brian