OpenLayers OpenLayers

Ticket #746 (closed feature: fixed)

Opened 1 year ago

Last modified 1 year ago

add() function should be tolerant to omitted y value

Reported by: euzuro Assigned to:
Priority: minor Milestone: 2.5 Release
Component: general Version: 2.4
Keywords: Cc:
State:

Description

in the add(x,y) functions on Pixel, LonLat, and Bounds, if user does not pass a y value, it causes errors.

Obviously, good form would dictate passing both, but out of kindness we ought to be nice and assume "0" if nothing is passed.

Attachments

forgiveness.patch (0.9 kB) - added by euzuro on 06/08/07 15:01:30.
if no value passed in, set to 0
noforgiveness.patch (6.6 kB) - added by euzuro on 07/11/07 15:08:21.
as suggested by all, let us not be forgiving. let us be erroring. yahoo!

Change History

06/08/07 15:01:30 changed by euzuro

  • attachment forgiveness.patch added.

if no value passed in, set to 0

06/08/07 15:32:10 changed by sderle

I don't think that the proposed behavior makes any sense. I'm -1 on this patch.

(follow-up: ↓ 3 ) 06/29/07 08:31:51 changed by crschmidt

Erik:

I can go either way on this, but I think this is just an issue of documentation. Add with a single parameter has multiple possible interpretations -- for example, I would have assumed that it would add the same value to both properties, not to just the x value. Perhaps this is a case where it would make sense to do nothing, and report an error via OpenLayers.Console.error(), rather than adding in too much magic here. Does that seem like a valid behavior?

Schuyler: Since you're -1, I'd like to hear what you propose as an alternative -- is what I mentioned above appropriate?

(in reply to: ↑ 2 ) 06/29/07 13:29:39 changed by euzuro

Replying to crschmidt:

Erik: I can go either way on this, but I think this is just an issue of documentation. Add with a single parameter has multiple possible interpretations -- for example, I would have assumed that it would add the same value to both properties, not to just the x value. Perhaps this is a case where it would make sense to do nothing, and report an error via OpenLayers.Console.error(), rather than adding in too much magic here. Does that seem like a valid behavior? Schuyler: Since you're -1, I'd like to hear what you propose as an alternative -- is what I mentioned above appropriate?

yeah, you're probably right. the magic argument is a strong one. (as is the argument that your natural interpretation differs from mine ;-)). Have we any examples yet in the code of using the console.error()?

I think this could be a good example.

06/29/07 13:32:33 changed by tschaub

This is now redundant, but I'll add it anyway (I was typing as the last comment was being added)

I'm -1 on this as well. I think forgiveness is good. I also think too much forgiveness of this type (or sanity patches) can make debugging hard. If a user passes one argument to add, they should know that it is wrong. They may, for example, pass in another pixel and assume that it is going to be added to the first. We've got the console now, we should at least be calling OpenLayers.Console.error (if not actually throwing an exception).

I know this goes against "be tolerant in what you accept" - but this comes from the perspective of a debugger. Debugging is hard. Most "bugs" in OpenLayers are user (or application developer) error. The more we swallow user errors, the harder it becomes to debug an application.

07/11/07 15:08:21 changed by euzuro

  • attachment noforgiveness.patch added.

as suggested by all, let us not be forgiving. let us be erroring. yahoo!

07/11/07 15:09:45 changed by euzuro

  • keywords set to review.

new patch added which introduces the first OpenLayers.Console.error() statements into the project. Hope we all like this. :-)

please review

07/13/07 09:34:52 changed by crschmidt

  • keywords changed from review to commit.

This is fine. Please commit.

07/13/07 11:42:47 changed by euzuro

  • status changed from new to closed.
  • resolution set to fixed.

fixed with r3731

07/13/07 11:48:11 changed by euzuro

  • keywords deleted.