Protected member variable vs. protected accessor methods

From: Andy Redman (andy.redman_at_NOSPAM.retail-j.com)
Date: 01/20/05


Date: Thu, 20 Jan 2005 10:00:40 +0000 (UTC)

Hi

I have a class (Java) with a private member variable. I now need to
extend the class to add a sub class which adds a new function. The new
function needs access to the member variable; at this moment it does
not need to alter the variable. As I see it I have two options, a -
make the member variable protected or b - add protected accessor
methods to the super class. Is there any general rule about which
approach to take.

Cheers,

Andy



Relevant Pages

  • Re: Protected member variable vs. protected accessor methods
    ... >> I have a class (Java) with a private member variable. ... >> extend the class to add a sub class which adds a new function. ... opinion. ...
    (comp.object)
  • Re: Java Singleton Constraint?
    ... it would seem that Java would not ... >allow a class to be derived from a Singleton. ... >that you must never have a need to extend the Singleton class? ... "The aim of science is not to open the door to infinite wisdom, ...
    (comp.object)
  • Re: Difference between two implementing the Thread
    ... There are two way of Thread Implementation ... Implementing the Runnable Interface ... be for you to extend the Thread class. ... Java programmer in the world reinventing his own Runnable, ...
    (comp.lang.java.programmer)
  • Re: compiling..
    ... not an interface ... Here it's actually similar to Java, that a class can extend only one ... implements IPostBackEventHandler, IPostBackDataHandler ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Unsigned bytes
    ... There is no reason that ... >Java promotes everything smaller than an int to int. ... The load-byte JVM instruction does a sign extend. ... http://mindprod.com Again taking new Java programming contracts. ...
    (comp.lang.java.help)