Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protect API against errant usage. #1

Open
mbostock opened this issue Aug 2, 2010 · 0 comments
Open

Protect API against errant usage. #1

mbostock opened this issue Aug 2, 2010 · 0 comments
Labels

Comments

@mbostock
Copy link
Contributor

mbostock commented Aug 2, 2010

The current API does not validate method arguments, coerce types, or make any defensive copies on input or output. This can lead to delayed failures; for example,

  • a div might be used for the map container rather than an svg
  • a string might be used for the map zoom rather than a number
  • the tile size might be set as a number rather than {x: number, y: number}
  • the lat or lon attributes of map.center() might be modified directly

Protecting against all types of errant usage might present an undue burden on the library implementors, but we should be able to protect against the more obvious mistakes and make the library more robust. The code size and runtime performance costs will hopefully be outweighed by the benefits of a easier debugging / more predictable failure modes.

Once all input types are appropriately coerced we should also be able to avoid the type-coercing equality operators; i.e., use === and !== instead of == and !=.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant