The Method on QueryIterator named AsPoints returns a pointer to an object of type PointValues. There is also the type Point.
Intuitively a developer could on first view expect a method named AsPoints to return an object of type or pointer to an object of type Point or a container holding objects of this type. When quickly coding Intellij IDE (And I imagine other IDEs as well) offers the Method AsPoints. Inattention to the actual return value can lead to this assumption. There are situations in which this misunderstood usage can compile, but at runtime leads to an NPE being thrown.
Expected behavior
Expect that a method returning a pointer or object of type PointValues to have a more intuitive name, when the return value can be confused with another type.
e.g.
func (i *QueryIterator) AsPointValues() *PointValues{...}
func (i *QueryIterator) AsValues() *PointValues{...}
Actual behavior
See Use Case section
Additional info
Changing the name of this method could of course break existing implementations. Adding this request for future discussion or review.
Use Case
The Method on
QueryIterator
namedAsPoints
returns a pointer to an object of typePointValues
. There is also the typePoint
.Intuitively a developer could on first view expect a method named
AsPoints
to return an object of type or pointer to an object of typePoint
or a container holding objects of this type. When quickly coding Intellij IDE (And I imagine other IDEs as well) offers the MethodAsPoints
. Inattention to the actual return value can lead to this assumption. There are situations in which this misunderstood usage can compile, but at runtime leads to an NPE being thrown.Expected behavior
Expect that a method returning a pointer or object of type
PointValues
to have a more intuitive name, when the return value can be confused with another type.e.g.
func (i *QueryIterator) AsPointValues() *PointValues{...}
func (i *QueryIterator) AsValues() *PointValues{...}
Actual behavior
See Use Case section
Additional info
Changing the name of this method could of course break existing implementations. Adding this request for future discussion or review.