Sangam


Laurie Williams, Lauren Hayward, and Xiao Bao [Contact Authors]
CSC 326 - Software Engineering
Department of Computer Science
North Carolina State University

Back to Software Engineering Tutorials


0.0 Contents
1.0 Introduction to Sangam
2.0 Setting Up Local Workspaces
3.0 Setting Up Sangam
4.0 Pair Programming
5.0 Exercise
6.0 Resources

1.0 Introduction to Sangam

Sangam is an Eclipse plugin that allows two developers to pair program from distributed locations. The users can view the same code and collaborate as they work together to write code.

Laurie Williams from North Carolina State University describes pair programming as, "Two programmers working side-by-side, collaborating on the same design, algorithm, code or test. One programmer, the driver, has control of the keyboard/mouse and actively implements the program. The other programmer, the observer, continuously observes the work of the driver to identify tactical (syntactic, spelling, etc.) defects and also thinks strategically about the direction of the work. On demand, the two programmers can brainstorm any challenging problem. Because the two programmers periodically switch roles, they work together as equals to develop software."

Sangam can be downloaded from the update site (http://sangam.sourceforge.net/plugin/site.xml) . For more information on installing eclipse plugins, consult the tutorial on the subject.

Top | Contents

2.0 Setting Up Local Workspaces

In this section, you will setup the HelloWorld project in two workspaces.

  1. For this tutorial, we will need two users: Lauren and Jason . You can work with another person on this tutorial and designate who will be Lauren and who will be Jason , or you can simply open two instances of Rational Team Concert on the same machine.
  2. We will be using the HelloWorld project. Lauren should download and unzip the HelloWorld project to her home directory and import the project into Eclipse. Please see the Rational XDE and Eclipse Import/Export Guide for instructions on how to import a project into Eclipse.
  3. It is important for both users to begin pair programming with identical files in their local workspaces. Both Lauren and Jason should connect to the same repository of the version control system of your choice. For instructions on how to connect to a Jazz Repository, view the Jazz tutorial, section 2.0, steps 4-7.
  4. Now Lauren needs to check-in and deliver the HelloWorld project to the repository. For instructions on how to check-in and deliver HelloWorld to a Jazz Repository, view the Jazz tutorial, section 3.0, steps 1-7.
  5. Jason needs to load the HelloWorld project from the repository. If you are using Jazz Source Control, complete the following actions to load the project:

    View the Pending Changes View by going to Window > Show View > Other... as shown in Figure 1.


    Figure 1. Opening a New View


    Select Jazz Source Control > Pending Changes. Click OK as shown in Figure 2.


    Figure 2. Opening Pending Changes View


    Expand the stream so you can view the components. Right-click on the component and choose Load.... as shown in Figure 3.


    Figure 3. Loading the Project


    To view the loaded project, go back to the Package Explorer by going to Window > Show View > Other... and selecting Java > Package Explorer. The HelloWorld Project loaded in the Package Explorer is shown in Figure 5.

  6. Figure 4. HelloWorld Project in the Package Explorer

Top | Contents

3.0 Setting up Sangam

Now that both Lauren and Jason have identical workspaces, we can setup Sangam.

  1. In order to begin, one partner needs to setup the Syncshare Server. The Syncshare Server hosts the connection between the two programmers. Jason should go to Window > Preferences (or Rational Team Concert > Preferences on Mac) and select Syncshare Preferences in the left pane.
  2. Jason should select the Data Directory. The Data Directory is where the information about the Syncshare Server will automatically be stored. Jason should click the Browse button next to Data Directory and select a directory.
  3. Jason should now select a password for the Syncshare Server. Enter the password and press Set.
  4. Jason should press the Start Server button.
  5. Now Jason needs to create a board, which is a group of users. Upon the driver making a change to a file, the driver's Sangam plugin will send a message to the Syncshare Server, which will send the same message to every user in the board. In the Boards frame, enter a name in the Board Name field, enter a password in the Password field, enter the same password in the Re-enter Password filed, and click Add.
  6. Now Jason needs to create a user for himself on the board. Select the board you just created in the Boards frame so that it is highlighted. In the Users frame, Jason should enter Jason in the User Name field, enter a password for himself in the Password Field, enter the same password in the Re-enter Password field, and press Add.
  7. Jason also needs to create a user for Lauren. Be sure the board is still highlighted in the Boards frame. In the Users frame, enter Lauren in the User Name field, enter a password for her in the Password Field, enter the same password for her in the Re-enter Password field, and press Add. Jason should tell Lauren her password.
  8. Jason's screen should look similar to Figure 6. Press OK.

  9. Figure 6. Setting Up the Synchshare Server

  10. Jason should locate his IP Address. If you are a Windows user, open Command Prompt and enter ipconfig. If you are a Mac user, open System Preferences > Network. Open the TCP/IP tab and your IP Address should be displayed.
  11. Now both Lauren and Jason need to input their board login information. Lauren and Jason should go to Window > Preferences (or Rational Team Concert > Preferences on Mac) and select Sangam Preferences. Next to Server Path, enter Jason 's IP Address. Next to Board Name, enter the name of the board Jason created. Enter the User Names and associated Passwords Jason created. Press Test. If your connection was successful, you will see Connection was successful as shown in Figure 7. If not, be sure you have entered Jason's correct IP Address, Jason's server is still running, and the user names and passwords are correct. Press OK.

  12. Figure 7. A Successful Connection to the Syncshare Server

  13. Finally, both Lauren and Jason need to associate Java Files with Sangam. Go toWindow > Preferences (or Rational Team Concert > Preferences on Mac). In the left pane, open General > Editors > File Associations. In the File Types box, select *.java. In the Associated editors box, select Sangam Editor as shown in Figure 8. Press the Default button. Select OK.


    Figure 8. Associating Java Files with the Sangam Editor

  14. If you cannot see the Sangam icons in your editor as shown in Figure 9, you'll need to change your preferences. Go to Window > Customize Perspective and open the Commands tab. In the Available command groups box, check the box next to Sangam Command Actions as shown in Figure 10. Press OK.

  15. Figure 9. Displaying Sangam Icons

Top | Contents


4.0 Pair Programming

After completing Sections 2 and 3 above, you are ready to start pair programming!

  1. Both Lauren and Jason should connect to the Synchshare server by clicking the Connect to Synchshare button. The icon will change to after connecting.
  2. By default, neither user is set to be the driver, and only one person can drive at a time. Lauren will drive first. Lauren should click the Start Driving button to begin driving and her icon will automatically change to to indicate she is driving. Jason 's icon will also automatically change to show that he cannot begin driving.
  3. Now Lauren needs to open a file and edit it. Lauren should open HelloWorld.java. The file will automatically open in Jason 's workspace. Lauren can edit the file and Jason will be able to see what she is typing. In the main method, add code to print the message, "Hi Jason !".
  4. Now it is Jason 's turn to drive. First Lauren will have to stop driving by clicking the button. Jason can begin driving by clicking the button.
  5. Jason can continue editing the same file. In the main method, Jason should add code to print the message, "Hi Lauren!"
  6. Continue programming until you are both happy with your code.
  7. When you are done pair programming, both Lauren and Jason should click the button to disconnect. The icon will turn red .
  8. Finally, check-in and deliver your code to your repository. Jason should check-in and deliver his code. Lauren should accept those changes and then check-in and deliver her code. You may have to resolve conflicts to deliver your code. For more on how to check-in and deliver changes along with how to accept changes using Jazz Source Control, see Section 3.0 of the Jazz Tutorial.

Top | Contents


5.0 Exercise
With your partner, connect to the same Syncshare Server and pair program. Show your TA your HelloWorld project with one partner driving and the other observing.
Top | Contents


6.0 Resources
Top | Contents

Back to Software Engineering Tutorials
Sangam ©2003-2008. North Carolina State University, Laurie Williams, Lauren Hayward, and Xiao Bao
Questions? Comments? Contact our mailing list

Last Updated: Monday, September 8, 2008 10:17 AM