• Prime Mover (unregistered)

"I measured my_thing.location last night."

• Industrial Automation Engineer (unregistered)

Yes. Coordinates are hard. Dates are hard. Basic Metric Units are also hard. To convert from m³ to liters, apperantly you only have to multiply by 100.

sorry for the rant. I wonder how my predecessor ever completed kindergarten. (did he?)

• (nodebb)

Through the whole process, everyone was testing their code, but the tests were driven by their assumptions about how the data should work- they expected the data in lat/lon, so they tested that the data was written (and retrieved) in lat/lon. All the lights on the dashboards were green, everyone was patting themselves on the back and celebrating a successful release.

If only there were systems to not require an implied ordering of an array. We could call it a "type of object". Python provides things called "classes"? Maybe those would work?

• SheriffFatman (unregistered) in reply to colejohnson66

Trouble is that geographical shapes can comprise hundreds or even thousands of points. For a text-based format like GeoJSON, using a simple pair of numbers rather than an object with explicit "lat" and "lon" properties saves a significant amount of space.

• Sole Purpose Of Visit (unregistered)

Well, frist, code reviews.

And in terms of unit tests, these unit tests were evidently very shabby. Test for negative co-ordinates. Test for max co-ordinates. Test latitudes and longitudes both against the implied (and bleeding obvious) range 0 .. 360. This stuff is not genius, but then again 99% of people who write tests are not geniuses.

• Sullivan (unregistered) in reply to SheriffFatman

{ "lat": [lat1, lat2, lat3, ...], "lon": [lon1, lon2, lon3, ...] }

• Sole Purpose Of Visit (unregistered) in reply to SheriffFatman

To which the simple answer is, use compression.

• Anonymous') OR 1=1; DROP TABLE wtf; -- (unregistered)

the residents of New York City would find themselves competing for subway space with the penguins of Antarctica

Yup, (74°S, 40°E) would put that in the middle of the Norwegian claim of Queen Maud Land, and not too far away from the Japanese research station Dome Fuji.

• MaxiTB (unregistered)

There is actually a long established way to spot mistakes like that: Code Reviews. Yeah, they are not perfect, but they are the only way to break out of tunnel vision. Side note: Nothing works if the review entity doesn't do its job properly, may it be manual, automatic test and of course reviews. That is not an argument for not doing them at all.

• Tim (unregistered)

TRWTF is TDWTF web site going down :)

only joking - TRWTF is not doing integration tests. IMO one integration test is worth about 100 unit tests

• tbo (unregistered) in reply to Sole Purpose Of Visit

Did you just say longitude goes from 0° to 360°?

I mean, that's wrong. It's -180° to 180°.

Super obvious, indeed.

• (nodebb)

I don't think this is super WTF-y. Unit tests only instead of unit tests + integration tests is bad, yes, but unit tests only is still better than no tests. (GeoJSON being an array instead of an object might be WTF-y, but with a large number of data points the space taken up by field names adds up. It's a tradeoff.)

I recently had a bug where I had to pack fields into a string to make a compound partition key in DynamoDB. I had the order wrong. I was even using a pre-built helper (but the wrong prebuilt helper.) Unit tests passed just fine, but things blew up in integration tests. And they only blew up because I was interacting with data generated by other parts of the codebase. Even the integration tests would have passed if it had been an isolated change.

Tests are not a magic bullet.

(Also, why is this a "Feature Article"? There's no storyline here. Not tale to tell. Methinks this is a CodeSOD.)

• a cow (not a robot) (unregistered) in reply to Sole Purpose Of Visit

Test for max/min coordinates? Wouldn't have helped, if they didn't know which coordinate was the lat and which one the lon...

• Charles (unregistered)

If the same person (or people) writes the tests as writes the code, then the tests will merely test that the code implements what they thought it should do, not check that it does the right thing. Testing must be done by other people, preferrably specialists.

• Fizzlecist (unregistered) in reply to Sullivan
Comment held for moderation.
• (nodebb) in reply to SheriffFatman

You could use `"N"` and `"E"` as your property names. While it still adds four characters per component, the advantage is that it is unambiguous and doesn't overturn a convention (latitude frist) that has stood for hundreds of years.

I mean seriously? When they came up with GeoJSON, did nobody contemplate the probability of people putting the coordinates the wrong way round?

• Moldavite (unregistered)
Comment held for moderation.
• banana (unregistered) in reply to Industrial Automation Engineer
Comment held for moderation.