Another newbie question

Bernhard Herzog bh at intevation.de
Sat Dec 10 19:50:58 EST 2005


aleax at mail.comcast.net (Alex Martelli) writes:
> You could make a case for a "2D coordinate" class being "sufficiently
> primitive" to have immutable instances, of course (by analogy with
> numbers and strings) -- in that design, you would provide no mutators,
> and therefore neither would you provide setters (with any syntax) for x
> and y, obviously.  However, a framework for 2D geometry entirely based
> on immutable-instance classes would probably be unwieldy

Skencil's basic objects for 2d geometry, points and transformations, are
immutable.  It works fine.  Immutable object have the great advantage of
making reasoning about the code much easier as the can't change behind
your back.

More complex objects such as poly bezier curves are mutable in Skencil,
and I'm not sure anymore that that was a good design decision.  In most
cases where bezier curve is modified the best approach is to simply
build a new bezier curve anyway.  Sort of like list-comprehensions make
it easier to "modify" a list by creating a new list based on the old
one.

   Bernhard

-- 
Intevation GmbH                                 http://intevation.de/
Skencil                                           http://skencil.org/
Thuban                                  http://thuban.intevation.org/



More information about the Python-list mailing list