"Gregory, Matthew" <[email protected]> wrote

. It seems like coding the Point class with multiple distance methods is not very flexible, especially if you wanted to iterate over those methods
for any two points

Its flexible enough provided you keep the interface to points. In other words if the distance is expressed as the difference between two points that can be worked out regardless of representation. The trick is to always keep the
interface as free of internal representation detail as possible.

However, you may not be able to provide concrete implementations of
those methods at the level of Point - which means Point turns into an
abstract class. Alternatively you may implement the methods in such
way that they call still other methods to perform data conversions
(polar-cartesian say) or generate default  values where none exist
- generating an X,Y from a list of dimensions maybe. And the Point
class implementation of those conversions may be trivial.

There are seveal ways to do this and none of them are perfect and none
of them are "right" - although a few of them might be considered "wrong"!.

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to