http://qs321.pair.com?node_id=512262


in reply to The Accessor Heresy

This may be an academic example, but it's very weird to see you set the area of a circle. Personally I'd have a constructor that takes two arguments or three arguments: either a point or two coordinates (this is open for debate) and the radius of the circle. I'd have a getter for the point and the radius, as well as getters for the area (which would be computed from the radius) and such other properties. Point may be an object if necessary, but it could also be coded as an x- and y-coordinate.

I'd (if necessary) have methods such as move to change the coordinates of the midpoint and scale to change the radius.

This seems to me the way to manipulate a circle without fussing with its implementation and that is after all one of the goals of OO.

Just my 2 cents, -gjb-

Update: Apparantly I should clarify a bit. The points I'm trying to make with my casual description of a Circle class are (at least ;) the following:

The former point is illustrated by the area example, the latter by the move method which could have been done just be modifying the coordinates of the midpoint.

As a last point: I don't care whether Radius is ann object or not since I'm not going to manipulate it directly in my example anyway.