Newsgroups: comp.lang.java,comp.object,comp.object.logic
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!newsxfer2.itd.umich.edu!chi-news.cic.net!ddsw1!news.mcs.net!idm.com!mongo.idm.com!plb
From: plb@idm.com (Peris Brodsky)
Subject: Re: Java public instance variables harmful?
Sender: news@idm.com (The News User)
Message-ID: <Do40ux.n3A@idm.com>
Date: Mon, 11 Mar 1996 15:40:08 GMT
References: <KRUSE.96Mar6131047@cms6.cern.ch> <4hkhnv$5ne@decaxp.harvard.edu> <Do28qp.IqL@idm.com> <4hv68t$et0@cnn.Princeton.EDU> <4i05f7$fl5@decaxp.harvard.edu>
Nntp-Posting-Host: mongo.idm.com
Organization: Information Data Management
X-Newsreader: TIN [version 1.2 PL2]
Lines: 29
Xref: glinda.oz.cs.cmu.edu comp.lang.java:30527 comp.object:45653 comp.object.logic:743

Keith Robison (robison@nucleus.harvard.edu) wrote:
> : In article <Do28qp.IqL@idm.com>, Peris Brodsky <plb@idm.com> wrote:
> : >Keith Robison (robison@mito.harvard.edu) wrote:

> : >> If you have no public instance variables and use methods to get & 
> : >> set values, it gives much more control & future flexibility.  
> : >> It's too bad the AWT designers have already set such a poor example
> : >> with Point, Dimension, Rectangle, etc.
> : >
> : >It DOES set a bad example, esp. considering the OOD acumen of
> : >the average Java hacker out there, but its justified for such
> : >primitive classes as these.  When will Point.x and Point.y ever
> : >disappear as integral fields?  

> Well, for one it means there's no way to make a const Rectangle
> object -- one that you know nobody you hand it to is going to
> muck with.  Of course, you could always clone the Rectangle
> -- except the AWT writers forgot to implement clone() for
> any of these "primitive" classes.  Ugh.  

> It also means I can't override their definitions.  Maybe

My point was that such primitive classes need not (and likely SHOULD
not, but that's another topic) be subclassed, since not a whole
lot of behavior can be reused.  Rather, just roll your own.

Peris L. Brodsky
IDM, Inc.
plb@idm.com
