Skip to main content

Timeline for Why do we need private variables?

Current License: CC BY-SA 3.0

4 events
when toggle format what by license comment
Dec 23, 2013 at 20:39 comment added supercat IMHO, there's nothing particularly wrong with having a public class whose sole purpose is to expose public variables. Indeed, the JVM has a number of built-in classes for that purpose: int[], double[], Object[], etc. One should, however, be very careful about how one exposes instances of such a class. The meaning of void CopyLocationTo(Point p); [accepting a Point from the caller] is clearer than Point location(), since it's unclear what effect Point pt = foo.location(); pt.x ++; will have on the location of foo.
S Apr 10, 2012 at 20:31 history suggested Peter Mortensen CC BY-SA 3.0
Copy edited.
Apr 10, 2012 at 20:19 review Suggested edits
S Apr 10, 2012 at 20:31
Apr 10, 2012 at 16:47 history answered Erik Reppen CC BY-SA 3.0