Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSC309 Lecture 09

CSC309 Lecture 09

Software Engineering II
Pair Programming
(202301)

Javier Gonzalez-Sanchez
PRO

January 29, 2023
Tweet

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. 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

    View Slide

  2. jgs
    Previously …

    View Slide

  3. jgs
    Fall 2022 | 00000001
    Key Ideas CSC 309
    idea
    requirements
    architecture
    design
    code
    quality measure

    View Slide

  4. jgs
    Pair Programming
    Reference:
    On Pair Programming by Martin Fowler (Agile, Architecture, Refactoring)
    https://martinfowler.com/articles/on-pair-programming.html

    View Slide

  5. 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

    View Slide

  6. 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.

    View Slide

  7. 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.

    View Slide

  8. 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.

    View Slide

  9. jgs
    Fall 2022 | 00000001
    In general

    View Slide

  10. 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.

    View Slide

  11. jgs
    A well-defined task
    We can use a compiler for our project

    View Slide

  12. 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.

    View Slide

  13. jgs
    Fall 2022 | 00000001
    Part 2
    public class Parser {
    private static Vector tokens;
    private static int currentToken;
    public static void rule_class () {}
    public static void rule_body () {}
    public static void rule_global_variable () {}
    public static void rule_method () {}
    public static void rule_instruction () {}
    public static void rule_local_variable () {}
    public static void rule_call_method () {}
    public static void rule_assignment () {}
    public static void rule_operation () {} // ignore precedence
    public static void rule_operand() {}
    }

    View Slide

  14. jgs
    Fall 2022 | 00000001
    Let’s Work

    View Slide

  15. jgs
    Test Yourselves

    View Slide

  16. jgs
    Fall 2022 | 00000001
    Case 1
    class Student{}
    Input:
    You have 1 class.
    Classes:
    * Student
    Methods:
    Relationships:
    Output:

    View Slide

  17. 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:

    View Slide

  18. 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:

    View Slide

  19. 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:

    View Slide

  20. 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:

    View Slide

  21. jgs
    Fall 2022 | 00000001
    Questions

    View Slide

  22. jgs

    View Slide

  23. 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

    View Slide

  24. 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

    View Slide

  25. jgs
    Fall 2022 | 00000001
    Let’s Work

    View Slide

  26. 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.

    View Slide