jgs CSC 309 Software Engineering II Lecture 09: Pair Programming Dr. Javier Gonzalez-Sanchez [email protected] users.csc.calpoly.edu/~javiergs | javiergs.com Building 14 -227 Office Hours: By appointment
jgs Pair Programming Reference: On Pair Programming by Martin Fowler (Agile, Architecture, Refactoring) https://martinfowler.com/articles/on-pair-programming.html
jgs Fall 2022 | 00000001 § Best programs and designs are done in pairs because you can criticize each other, find each other’s errors, and use the best ideas. - Jean Bartik (one of the very first programmers) § Write all production programs with two people sitting at one machine. - Kent Beck (Agile, JUnit) Pair Programming
jgs Fall 2022 | 00000001 Process § The process starts with the developers receiving a well-defined task. § They agree on one small goal at a time. § They take turns to code or review each other's work. § Rotating roles regularly helps keep both developers alert and engaged. § Enable senior developers to share their knowledge and working habits § Help new team members get up to speed on a project.
jgs Fall 2022 | 00000001 Roles § Driver (the person on the keyboard). Focused on completing the tiny goal at hand, ignoring larger issues for the moment. A driver should always talk through what they are doing while doing it. § Navigator (the person observing). They review the code on the go, gives directions, and shares thoughts. They have an eye on the larger issues, and bugs, and make notes of potential next steps or obstacles. They are in control of the strategic or architectural elements. As a navigator, leave the details of the coding to the driver – your job is to take a step back and complement the driver’s tactical mode with medium-term thinking.
jgs Fall 2022 | 00000001 Problem • Equally engaging pairs. If both developers do not equally engage in the project, then there is less chance that knowledge will be shared • Social and interactive process. It is hard for those who work better alone.
jgs Fall 2022 | 00000001 So, best practices • Consistent communication • Switch roles • Pair up carefully (select your pair). • A familiar development environment • Work at a pace that fits both developers.
jgs Fall 2022 | 00000001 Part 1 1. Read a File and Split the lines 2. For each line read character by character 3. Concatenate characters, creating the largest STRING possible. Stop when a delimiter, white space, operator, or quotation mark is found. If there are more characters in the line, go to step 2. 4. Bonus points: for each STRING report its TYPE as correspond. E.g., class is a keyword, { is a delimiter, hello is a name (identifier), Student is a name (identifier), + is an operator, extends is a keyword, etc.
jgs Fall 2022 | 00000001 Case 2 class Student{ Hello world } Input: You have 2 class. Classes: * Student * Hello Methods: Relationships: * Student has a Hello Output:
jgs Fall 2022 | 00000001 Case 3 class Student extends Person{ Hello world } Input: You have 3 classes. Classes: * Student * Person * Hello Methods: Relationships: * Student has a Hello * Student is a Person Output:
jgs Fall 2022 | 00000001 Case 3 class Student extends Person{ Hello world } Input: You have 3 classes. Classes: * Student * Person * Hello Methods: Relationships: * Student has a Hello * Student is a Person Output:
jgs Fall 2022 | 00000001 Case 4 class Student extends Person{ Hello world() { } } Input: You have 2 classes. Classes: * Student * Person Methods: * world Relationships: * Student is a Person Output:
jgs CSC 309 Software Engineering II Lab 09: Code Review Dr. Javier Gonzalez-Sanchez [email protected] users.csc.calpoly.edu/~javiergs | javiergs.com Building 14 -227 Office Hours: By appointment
jgs Fall 2022 | 00000001 Think about this 1. Select your pair 2. Understand the task (described before) 3. Chose and set up your environment 4. Be ready to work
jgs CSC 309 Software Engineering II Javier Gonzalez-Sanchez, Ph.D. [email protected] Winter 2023 Copyright. These slides can only be used as study material for the class CSC308 at Cal Poly. They cannot be distributed or used for another purpose.