[ 
https://issues.apache.org/jira/browse/GEOMETRY-111?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Baljit Singh updated GEOMETRY-111:
----------------------------------
    Description: 
Using a Point/Vector interface (especially, the self-bounded/referencing 
{{Point<P extends Point<P>>}}), leads to awkward use of Java generics in other 
classes. The need is understood in that it makes things "easier" within the 
subclasses, but it does make other APIs and method signatures a lot more 
complicated.

Instead, I would propose a {{Metric<P>}} interface, with a single method 
{{double distance(P start, P end)}}. This makes the API a lot more flexible. 
For example, using the same point type ({{Vector3D}}), one can define two 
metrics (Euclidean distance for Cartesian space, and angle for Spherical 
space). 

I understand that it is difficult to prove the usability case, but I'm speaking 
from experience, having implemented both ways in other libraries.

  was:
Using a Point interface (especially, the self-bounded/referencing {{Point<P 
extends Point<P>>}}), leads to awkward use of Java generics in other classes. 
The need is understood in that it makes things "easier" within the subclasses, 
but it does make other APIs and method signatures a lot more complicated.

Instead, I would propose a {{Metric<P>}} interface, with a single method 
{{double distance(P start, P end)}}. This makes the API a lot more flexible. 
For example, using the same point type ({{Vector3D}}), one can define two 
metrics (Euclidean distance for Cartesian space, and angle for Spherical 
space). 

I understand that it is difficult to prove the usability case, but I'm speaking 
from experience, having implemented both ways in other libraries.


> Metric interface instead of Point/Verctor interface [BREAKING CHANGE]
> ---------------------------------------------------------------------
>
>                 Key: GEOMETRY-111
>                 URL: https://issues.apache.org/jira/browse/GEOMETRY-111
>             Project: Apache Commons Geometry
>          Issue Type: New Feature
>            Reporter: Baljit Singh
>            Priority: Major
>
> Using a Point/Vector interface (especially, the self-bounded/referencing 
> {{Point<P extends Point<P>>}}), leads to awkward use of Java generics in 
> other classes. The need is understood in that it makes things "easier" within 
> the subclasses, but it does make other APIs and method signatures a lot more 
> complicated.
> Instead, I would propose a {{Metric<P>}} interface, with a single method 
> {{double distance(P start, P end)}}. This makes the API a lot more flexible. 
> For example, using the same point type ({{Vector3D}}), one can define two 
> metrics (Euclidean distance for Cartesian space, and angle for Spherical 
> space). 
> I understand that it is difficult to prove the usability case, but I'm 
> speaking from experience, having implemented both ways in other libraries.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to