Thursday, July 05, 2007

Facebook App In Progress

Looking over the open source F8 app by NewsCloud. I may post a UML diagram if I have some time to kill, but essentially it breaks into these parts:

  1. init tasks
  2. Facebook input processing
  3. Response processing
Item 1 is accomplished through some very reasonable ctor code and PHP classes. (They seem to be using PHP4.) This pulls in their underlying libraries for SQL access, templating, formatting, etc. Don't know why they rolled their own in some cases (why not use Smarty for templates?)

Item 2 is stock F8 code, with some commercial-grade checking and error handling.

Item 3 is a big switch statement, keyed on the HTTP request input. The main cases correspond to pages: home, search, news, video, etc. Why they chose this over a true MVC framework is probably to simplify their life, since this is a relatively small app. Something like Cake or Symfony I am guessing would have been overkill. I like it; it's simple and clear and easy to understand, even if a bit hardcoded. Sometimes hardcoded is good. That's what they don't teach everyone ;)

What I really wanted to see was the fbml tags they were using, and how, and how they were formatting stuff. The tags they use are:
  • tabs
    • tab-item
  • message
  • notif-subject
  • iframe
  • req-choice
  • swf
  • friend-selector
  • share-button
  • userlink
  • wide
  • if-can-see
  • profile-pic
  • name
  • header
Their fbNewsCloud class has these methods, which essentially map to the anticipated use cases, and probably are good use cases for most F8 apps to consider:
  • buildNav - navigation dashboard div
  • buildStyles - adding CSS defs
  • buildSWF - for their video feeds
  • getNews/buildStoryLink - uses their templater class to build out the data from the DB...essentially this would be the heart of your service...getFoo()
  • getYourFriends - Got Viral? This is where you win big on the community angle - see what my friends are doing with this app
  • buildStory - Viral++ a bit of a misnomer, this builds the sharing link for the content...a must have for social capitalists
  • buildCommentThread - let yoru voice be heard, and those of others
  • getCloudList/fetchCloudStories - their concept of categories/groups
  • getClips/fetchClips/buildVideoLink - video clips
  • recordAction - keep a record of what the user is doing, a F8-ish concept as well as useful for mining
  • updateProfileBox/buildProfileBox/buildActionList/listActions - builds the fbml for the F8 profile widget; I would assume a necessary F8 component
  • getFriendsNews - related to the profile list, virulent strain
  • fetchSearchResults - search box
  • getWhatsHot - or not
  • friendsUsingApp/friendsNotUsingApp (and getInviteList/addToInviteList/updateLastInvite) - a.k.a. VP-Marketing-killer...why hire an MBA when the user can market your wares for you?
  • lookupFacebookUser - for invites
  • setInstalled/isAppInstalled - fql to see if we are installed
  • mapUser - they tie their users to F8 users; hmm OpenID anyone??
  • fetchAd - Aaah, need to pay the bills, eh?
  • buildGettingStarted/buildLeftIntro - the F8 add app call to action
  • setupTemplates - calls into the NC library of goodies and uses DB+minimal templates
Overall this leads to a good template for most F8 applications:
  1. Parse out the info sent back by Facebook
  2. template the responses
  3. separate logic from presentation code (MVC)
  4. follow key Facebook styles and concepts - dashboard, profile, friend list, etc.
Still, both the FBUtils.class and the NewsCloud.class don't really seem to be OO --- other than they encapsulate some values as members. If however, there was a base class for multiple social services, then having a polymorphic hierarchy might be useful.

In addition the the F8 logic, some controller code is required. NewsCloud puts this into a process.php file.

Now, to understand more about how to MARKET a F8 app once you've created it....that's for next time!

No comments: