I generally like to use the gettor/settor exclusively,  even from within the 
class hierarchy.  Makes it consistent.
----- "Adrian Crum" <[email protected]> wrote:

> Adam Heath wrote:
> > ComparableRange has inconsistent access to the instance variables
> of
> > other ComparableRanges.  There are several methods that do some
> kind
> > of comparison with another range.  Sometimes, those methods call
> the
> > accessor methods.  Other times, direct variable access is used.
> > 
> > Here's my take on this issue, based on the Concurrency in Practice
> > book.  If ComparableRange is final, and not meant to be extended,
> then
> > always do direct access, period.  If ComparableRange is supposed to
> be
> > extended by other classes, then make the instance variables
> final(to
> > force extended classes to use the accessors), then the base class
> > always must use the accessors.
> 
> Consistency would be nice. My personal preference is to avoid making 
> classes final because a user might want to extend a class's behavior.

Reply via email to