Sunday, December 13, 2009

First Facebook app

I wrote a silly little Facebook app (Are you prime?) that checks if a Facebook user's ID is a prime number. It also goes through the friends list and does the same check.

Some issues I've found:
  • How do I deal with the scaling problem if someone has a large number of friends? Can my app even finish fetching the list without timing out? It looks from the API documentation that this is an all-or-nothing request.
  • I used phpseclib to perform the primality testing. I'm quite certain that it has a major bug in that it determines all integers 3 <= n <= 1000 are composites. I added a work-around, but it makes me wonder if there are other major bugs that would have embarassing effects on my app. I would hope that something so simple would at least be correct.
I don't have time to implement all this, but here are some ideas:
  • Compute other mathematical properties about the number. Make the app find as many interesting thing as possible with any number. Of course, this would now become obvious Wolfram Alpha territory.
  • Animated trial-division factorization using client-side Javascript. This is actually not a half-bad idea.
  • Find interesting facts in pairs of numbers (i.e. a user's ID and one of his/her friends'), e.g. point out friendly pairs, sexy primes, etc.
  • Deal with the large friends list problem by making the app more dynamic. Maybe integrate this feature with the previous one, e.g. let users select a bunch of friends and then say something mathematically interesting about the whole group ("You're all members of a prime constellation!").
  • Log usage information to database.
Some comments on the social aspect of the app:
  • I really like the fact that right now my app encourages user-to-user connection by looking if any of a user's friends have prime IDs, and making it convenient for them to post on other people's wall to share this discovery. This way, even if a user is not prime, they can still potentially get something rewarding out of it.
  • Make it competitive by assigning points for having a prime user ID and for knowing people who do. This may lead to people aggressively seeking to connect with other people, although there will be obvious bias with people gravitating toward those whose user ID are primes.

No comments:

Post a Comment