5 FaceBook Source Code Secrets
By Angsuman Chakraborty, Gaea News NetworkWednesday, August 15, 2007
I glanced over the Facebook source code for both index and search pages. As an enterprise developer of some experience, source code is always interesting to me as it provides an insight into the health of a company. The interesting highlights of the Facebook code are:
1. Facebook writes pretty clean code & maintains coding standards. The code is readable.
2. To Facebook coder: Calling a function to do the magic isn’t an example of clean code; in response to Facebook coders comment - “Holy shit, is this the cleanest fucking frontend file you’ve ever seen”
3. Facebook doesn’t do MVC. There isn’t any separation of concerns as far as I could see. It is also not a designer’s job. It is created by developers with tons of procedural PHP code.
4. Facebook also doesn’t do much object oriented coding either, at least it wasn’t apparent from these source files. It is plain and simple procedural code.
5. Facebook uses templates which is nice.
It does some interesting stuff with advertising, specifically estimates the length of page and attributes to determine advertisements to show. There are few interesting ideas here.
Did you expect more? There isn’t much more really, take a look yourself. I wonder if MySpace’s code is as clean.
Tags: Software Review
Gio |
January 16, 2010: 6:19 am
Great info there! Now all I have to do is stop being lazy and actually make one! |
Chad Lee |
June 17, 2009: 8:00 am
include_once $_SERVER['PHP_ROOT'].’/html/init.php’; include_once $_SERVER['PHP_ROOT'].’/lib/home.php’; // lib/display/feed.php has to be declared here for scope issues. // require login // Check and fix broken emails // migrate AIM screenname from profile to screenname table if needed // homepage announcement variables // redirects include_once $_SERVER['PHP_ROOT'].’/lib/mesg.php’; // todo: password confirmation redirects here (from html/reset.php), param_get_slashed(array( param_post(array( // homepage actions // upcoming events // this is all stuff that can be fetched together! $targeted_data = array(); // Merman’s Admin profile always links to the Merman’s home if (is_array($upcoming_events)) { tpl_set(’upcoming_events’ , $upcoming_events); // disabled account actions // new pokes (no more messages here, they are in the top nav!) // get announcement computations // birthday notifications // user info // decide if there are now any requests to show $permissions = privacy_get_reduced_network_permissions($user, $user); // status if (!empty($presence) && $presence['status_time'] > (time() - 60*60*24*7)) { tpl_set(’show_status’, $show_status = !$orientation); // orientation // timezone - outside of stealth, update user’s timezone if necessary // set next step if we can // note: don’t make this an else with the above statement, because then no news feed stories will be fetched if they’re exiting orientation require_js(’js/dynamic_dialog.js’); if ($post_hide_orientation && $post_hide_orientation <= $ORIENTATION_MAX) { $stories[$ORIENTATION_ORDER[$ORIENTATION_NETWORK]]['join_pending'] = array( // Mobile web API params if (orientation_eligible_exit($orientation)) { //if in orientation, we hide all feed intros (all 1’s in bitmask) } // Rooster Stories // set the variables for the home announcement code tpl_set(’hide_announcement’, $hide_announcement_tpl); $show_friend_finder = !$orientation && contact_importer_enabled($user) && !user_get_hiding_pref($user, ‘home_friend_finder’); $account_info = user_get_account_info($user); tpl_set(’show_friend_finder_top’, tpl_set(’user’, $user); // MONETIZATION BOX if ($show_monetization_box) { // ORIENTATION tpl_set(’simple_orientation_first_login’, $get_o); // unused right now // Roughly determine page length for ads // page length using feed stories $feed_stories = null; $feed_off = false; if (check_super($user) && $get_feeduser){ // Friend’s Feed Selector - Requires dev.php constant $feed_stories = feed_adjust_timezone($user, $feed_stories); tpl_set(’feed_off’, $feed_off ? redirect(’privacy.php?view=feeds’, null, false) : false); render_template($_SERVER['PHP_ROOT'].’/html/home.phpt’); include_once $_SERVER['PHP_ROOT'].’/html/init.php’; include_once $_SERVER['PHP_ROOT'].’/lib/home.php’; // lib/display/feed.php has to be declared here for scope issues. // require login // Check and fix broken emails // migrate AIM screenname from profile to screenname table if needed // homepage announcement variables // redirects include_once $_SERVER['PHP_ROOT'].’/lib/mesg.php’; // todo: password confirmation redirects here (from html/reset.php), param_get_slashed(array( param_post(array( // homepage actions // upcoming events // this is all stuff that can be fetched together! $targeted_data = array(); // Merman’s Admin profile always links to the Merman’s home if (is_array($upcoming_events)) { tpl_set(’upcoming_events’ , $upcoming_events); // disabled account actions // new pokes (no more messages here, they are in the top nav!) // get announcement computations // birthday notifications // user info // decide if there are now any requests to show $permissions = privacy_get_reduced_network_permissions($user, $user); // status if (!empty($presence) && $presence['status_time'] > (time() - 60*60*24*7)) { tpl_set(’show_status’, $show_status = !$orientation); // orientation // timezone - outside of stealth, update user’s timezone if necessary // set next step if we can // note: don’t make this an else with the above statement, because then no news feed stories will be fetched if they’re exiting orientation require_js(’js/dynamic_dialog.js’); |
sn!z |
Jack |
8100030d