- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I'm reminded of Adrian Mole:
"I measured my_thing.location last night."
Admin
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?)
Admin
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?
Admin
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.
Admin
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.
Admin
{ "lat": [lat1, lat2, lat3, ...], "lon": [lon1, lon2, lon3, ...] }
Admin
To which the simple answer is, use compression.
Admin
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.
Admin
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.
Admin
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
Admin
Did you just say longitude goes from 0° to 360°?
I mean, that's wrong. It's -180° to 180°.
Super obvious, indeed.
Admin
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.)
Admin
Test for max/min coordinates? Wouldn't have helped, if they didn't know which coordinate was the lat and which one the lon...
Admin
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.
Admin
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?