21 August 2008

Note to self

If you ever have to implement a service that needs the user location, don't rely on the address (messy, error-prone due to misspelling, nonstandard across countries...). Just use a GoogleMap widget and then store the coordinates, plus a free-form text field if you really need the address (e.g. for mailing etc).

This system will scale effortlessly and it will be much simpler to implement lookups like "people near you in a 5-miles radius". You might want to store the country in a separate field for i18n purposes, but even with that, you will have 3 fields (coordinates, free-form address, country) vs umpteen (house/flat number, block name, two or three lines which might not even be enough for some users, town, city, district, postcode with format differing by country etc etc...) which are very hard to use in a geo-aware way.

(This presumes that you are starting from scratch; if you have to bidirectionally interface with legacy systems, chances are that you'll need to stick with the bad ol' stuff).

2 comments:

gpiancastelli said...

Have you noticed that in the interface for inserting new books aNobii lets you specify the price you paid? Of course I suppose that such information is not accessible via the aNobii API... but what about GR? Has it something similar? In that case, the Amazon WS would be needed only for gifts and such... Also, uhm, did you think about distinguish purchased books from books that the reader has borrowed from a library?

GiacomoL said...

"How much you paid" can be significantly different from "how much it's worth now". In aNobii you can write down how much you paid (I don't think GR has that feature), or even the cover price, but if Amazon says that the book is now worth 10 times more, what's the real value? Market price and cost are two quite different concepts! :D
You can separate purchased vs borrowed books just by creating different shelves in GR. It would be interesting to have a few people borrowing from the same library tagging their shelf with a common word, then running the script, and see how much money a library saves to the individuals and to society...