[Edu-sig] Uniform Access Principle confusion

Kirby Urner urnerk at qwest.net
Wed Oct 12 20:24:58 CEST 2005


> In the case of Kirby's Triangle angle, might it be wise to avoid the
> possibility of exploding any spacecraft, and insist that a contract be
> formed with the caller so that the caller must specify whether they are
> expecting the return value in radians or degrees?  Seems maybe yes.  But
> that requires a parameter, though changes nothing else about what the
> angle is in relation to the Triangle.
> 
> So the UAP is not getting through here.
> 
> Art

Note that passing an argument is not the only way to tell an object stuff
like "my preferred unit of measure."  That could also be regarded as a
change in state, and be handled with another attribute, e.g.:

  >>> Triangle.anglemeasure = 'degrees' # set default class attribute
  >>> mytri = Triangle((30,60,90))      # instantiate using degrees
  >>> mytri.anglemeasure = 'radians'    # change state on instance
  >>> mytri.C                           # consult angle
  1.5707963267948966
  >>> mytri = mytri * 2                 # double size -- angles unaffected
  >>> mytri.anglemeasure = 'degrees'    # change reporting unit
  >>> mytri.C                           # consult angle (again)
  90.0

I'm not claiming this approach is in any ultimate sense better.  I'm merely
pointing out that this is another approach.

Kirby




More information about the Edu-sig mailing list