FacePamphlet: Implementing a Simple Social Network

Mehran Sahami
Stanford University

Summary FacePamphlet: a simple social networking application. Makes use of objects, GUI interactors, simple data management (HashMaps and ArrayLists), and solid understanding of control flow to make an application that manages a "light" version of FaceBook (hence the name of the assignment).
Topics Objects, GUI interactors, data collections (HashMaps and ArrayLists), understanding of control flow and state.
Audience Could be used in a CS1 or CS2 course (depending on how much complexity the instructor wanted to add). The version written here was used as a final assignment in a CS1 course.
Difficulty This is an advanced CS1 assignment, taking 1 to 2 weeks for a CS1 student.
Strengths Topic of assignment (social networks) is something students are excited about and feel empowered by when they realize they can create such an application themselves (and show it to their friends). While stressing solid data collection manipulation and state-based control-flow, the assignment also has many potential ways it can be modified or extended, with open-ended options to let students really explore.
Weaknesses There are lots of cases to consider in the interaction a user may have with the application. While dealing with these cases is not difficult, it just requires that students think about all of them and results in a long handout to explain all the possibilities.
Dependencies The assignment presented here relies on the ACM Java libraries, but it could be modified to just use standard Java if one were so inclined. The assignment also requires students to understand an event-driven model as a result of the GUI interaction model.
Variants You can really come up with whatever kinds of variants of the social networking application you like by (for example) changing what information is stored/displayed in a user profile, how the GUI is displayed, what links in the network represent, the addition of user groups (i.e., class hierarchy of profile types), file read/write of the network, etc. At the end of the day, the "social network" is really a graph, so in the most general sense this program is really about the creation/manipulation of a graph and you could have many application "themes" that use the basic format of the assignment.

Social networking is a topic that many students are actively engaged in (some might even argue too engaged in). In any case, it is a topic that really captures student interest in a programming course as it provides an opportunity for students to be the implementor of something that they have been a comfortable user of for some time. Moreover, it provides a rich context for exercising many programming concepts (control flow, state, data management, object-oriented design, event-driven programming, etc.).

This assignment was given as the final programming project in a quarter-long CS1 course using Java and the ACM libraries. The assignment ranked second in terms of student end-of-term surveys as their "most liked" assignment (out of seven assignments in the course). It ranked behind "Breakout" and ahead of "NameSurfer", both of which are previous Nifty Assignments. Interestingly, however, there was a gender bias in these preferences. While the overall class was roughly 40% female and 60% male, FacePamphlet (as opposed to either Breakout or NameSurfer) was disproportionately preferred as a favorite assignment by women, as the following break down shows:

Of students whose favorite assignment was...% female% male
Breakout33 % 67 %
NameSurfer36 % 64 %
FacePamphlet42 % 58 %

The handout for the FacePamphlet assignment is available here.

Thh "starter bundle" containing the starting code is here.

An applet of the basic program is available below. (Note: The applet below only supports two profile pictures/images: "StanfordLogo.jpg" and "StanfordTree.jpg"). To run the extended version of the program that support loading and saving of social networks, you should use the demo available in the file FacePamphlet-withLoadSave.zip.

The version of the assignment presented here focuses on control flow (while keeping track of minimal application state), data structure manipulation (HashMaps and ArraysLists), and GUI interactors. The assignment could be expanded/modified along a number of different dimensions, such as:

Broader Social Narrative

In giving this assignment, it is also worthwhile to give students a bit of backstory on the development of Facebook. Notably, Facebook was originally developed in 2004 by Mark Zuckerberg (and friends) while he was a sophomore at Harvard University studying Computer Science. Given that Zuckerberg's age at the time of starting Facebook is comparable to that of many students in CS1/2, it helps create a compelling story that the skills students are learning in their CS courses (notably the FacePamphlet assignment they are working on) can empower them to do something similar.

Extra info about this assignment: