![]() |
|
Keep It Simple, Stupid | |
PerlMonks |
Re: The Accessor Heresyby gjb (Vicar) |
on Nov 28, 2005 at 16:40 UTC ( #512262=note: print w/replies, xml ) | Need Help?? |
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:
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.
In Section
Meditations
|
|