[Edu-sig] Design Patterns

Scott David Daniels Scott.Daniels at Acm.Org
Sat Aug 27 23:44:12 CEST 2005

Arthur wrote:
> I have a line segment - defined as the segment connecting 2 points.  The
> interface allows the points to be picked and moved.
> The line segment has a length.  I choose line.getLength() as my API .... 
> Am I - in fact - violating the Uniform Access Principal. 
> If I am, am I violating good programming practice?

OK, my take is no -- you are choosing an API.  My strongest reaction has
to do with your wish to deny me the ability to make another choice; API
design is an art, not a science, and not engineering.  The whole API
is what you should evaluate.  I am certain we cannot produce a set of
rules that guarantee a good API, not can we provide rules to avoid a
bad API.

> If I am not violating the Uniform Access Principal how do we express on what
> basis I am not?

This to me has to do with the set of calls in your API.  It is hard to
say with a coordinates and length API, it is easier with something
richer like triangles, rectangles, and polygons.  The length of the
sides of all of those things should show up the same way; either as
attributes or method calls.  Variations between polygons and triangles,
for example, would make me think you are letting your implementation
show through too much.

--Scott David Daniels
Scott.Daniels at Acm.Org

More information about the Edu-sig mailing list