1
e03
CS56 f18
PLEASE DO NOT WRITE IN THIS AREA! Name: Seat:
(as it would appear on official course roster)
Umail address: @umail.ucsb.edu

EXAM: e03: Final

ready? date points
true Tue 12/11 12:00PM

You may not collaborate on this exam with anyone. If you need to use the restroom, you must leave your cell phone with the exam proctor before leaving the room.

  • Write your name at the top of this page AND EVERY ODD NUMBERED PAGE.
  • Double check that you turned in ALL pages; look for "End of Exam" on the last page.
  • This exam is closed book, closed notes, closed mouth, cell phone off.
  • You are permitted one sheet of paper (max size 8.5x11") on which to write notes.
  • This sheet will be collected with the exam, and might not be returned.
  • Please write your name on your notes sheet.

  1. To prepare for our discussion of User Stories, as they are used in Agile software development, we read an article that described something called a “product backlog”.

    1. (3 pts) What is a product backlog?

    2. (3 pts) While working on the team projects in this course, how did we keep track of our product backlog? For full credit: be specific about what tool was used, and how it was used.

  2. Figure A

    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.4</version>
        <scope>provided</scope>
    </dependency>
    
    <dependency>
      <groupId>org.jacoco</groupId>
      <artifactId>org.jacoco.core</artifactId>
      <version>0.8.2</version>
    </dependency>
    
    

    Throughout the second half of the course, we used Maven as our build tool. Occasionally, we had to deal with code such as that shown in Figure A, adding it to a particular file in our project.

    1. (2 pts) What is the name of the file this code is added to? Please write the filename in the box below.

      answer
       
    2. (2 pts) Inside a git repo for a project, where would this file be located? (Multiple choice)

      In src/main/java In src/main/resources At the top level directory In target/site
    3. (5 pts) Explain why you would need to add a <dependency> elements to that file (i.e. the one you named above.) In your answer, focus the purpose of <dependency> elements in general, not on the two specific ones shown (i.e. don’t answer about lombok or jacoco specfifically.)

  3. (20 pts) For this problem, you may find it helpful to consult the reference material regarding interfaces and methods related to sorting on Handout A.

    • Below, you will code for the file MenuItem.java.
    • Alter this code so that an ArrayList<MenuItem> called menu can be sorted by name using this line of code:

       java.util.Collections.sort(menu);
      

    Make the two changes needed, directly on the listing below.
    You may cross out code, and/or write new code where it belongs.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    
    public class MenuItem {
    
        private String name;
        private int priceInCents;
        private String category;
    
        public MenuItem(String name, int priceInCents, String category) {
          this.name = name;
          this.priceInCents = priceInCents;
          this.category = category;
        }
    
        public String getName() { return this.name;}
    
    
    
    
    
    
    
    }
    
  4. Please answer the following multiple choice questions:

    1. (3 pts) If a class of type T implements the java.lang.Serializable interface, it provides which of these capabilities:

      The ability to give each instance of the object a unique “serial number” to identify that object, accessible using the public int getSerial() method.
      The ability to save the state of objects in a Java-specific binary format that can persist after the jvm shuts down, and be restored later on any compliant jvm implementation
      The ability to sort objects according to their “natural order”
      The ability to add objects to an instance of java.util.Queue<T> and remove them in a thread safe manner, preserving order
      None of the above
    2. (3 pts) Assume the following code appears inside a main() method of a Java class.

        int x = 1;
        while (x) {
          System.out.println("foo");
          x++;
        }
      

      Which is a true statement about this code?

      It will print foo on standard output, one “foo” per line, forever, or until the program is terminated
      It will print foo on standard output, one foo per line, until the value of x exceeds
      the maximum value for an int in Java (i.e. 232 - 1), at which point a RangeException will be thrown.
      It will print foo on standard output, one “foo” per line, until the value of x wraps around to the largest negative integer, i.e. -232, and then climbs back up to zero. At tha point, the condition will be false and the loop will halt.
      It is a syntax error, because int values cannot be treated as boolean values in Java
      None of the above
  5. For this question, and ALL of the remaining questions on this exam, please focus on your web application project.

    Please write clearly; your answer will be graded on clarity as well as content. Minor grammar/spelling errors will not cause deductions, as long as the meaning is clear—errors that make the meaning difficult to understand will result in deductions.

    (10 pts) Every application should meet some need that the user has, or help them acheive some goal. What is the name of your app, and what is the goal, or need that a user of your app can get met by using your app?

  6. (10 pts) As in the previous question, please focus on your web application project, and write clearly, answering as if you were in a job interview.

    As you know, each team worked with one another to divided up issues among the team, assigning issues either to individuals, pairs, or larger groups. Describe one particular issue that you personally worked on, focusing for this question on the technical aspects (i.e. the coding aspects).

    For full points, it must be clear from your answer that you have a firm grasp of whatever technical aspect of the problem you are describing, and that you made a signficant contribution.

    For example:

    • if you say: “I worked with two other people to set up the database”, include in your answer which database technology you used, and some of the details of the steps involved in setting up a database using that technology.
    • if you say: “I worked on the front end”, be specific about the details of HTML/CSS/JavaScript that you contributed, so that it is clear that you have a good grasp of the technical issues involved.

    Finally, in your answer, include the “definition of done” for your issue.

  7. As in the previous question, please focus on your web application project, and write clearly, answering as if you were in a job interview.

    Once the project phase of the course began, we held “standup” meetings (also sometimes called “scrum” meetings) at every lecture and lab.

    1. (5 pts) What is the purpose of an Agile standup meeting?

    2. (10 pts) Think of a specific agile standup meeting that you participated in during this quarter. To the best of your recollection, write down what you said at that meeting.

      (BEFORE YOU PANIC, READ THIS: The purpose of the question is to check your understanding of what someone is supposed to share during a standup when it is their turn to speak, as well as to check that you actually participated in your groups’ standup meetings on a regular basis. You don’t have to recall what you said word-for-word; I just want to see a representation of what you contributed at your standups and how you participated.)

  8. As in the previous question, please focus on your web application project, and write clearly, answering as if you were in a job interview.

    Think carefully before you start answering this question. It will require some planning and thought.

    We learned about Design Patterns in general, and specifically about the strategy pattern.

    The “Strategy Pattern”, one that enables selecting an algorithm at runtime, and encapsulates the selectable algorithm in an interface, and classes that implement that interface. There are typically at least three types of components:

    • a client class that selects a behavior (e.g. the Duck)
    • the strategy interface that abstracts the behavior (e.g. FlyBehavior)
    • concrete implementations of the behavior (e.g. FlyWithWings, FlyNoWay)

    In this question, I want to see if you really understand what all that means and are able to apply it.

    Think of a specific future feature that could be added to the your webapp project where the strategy pattern might be applicable. Think of what the client class, strategy interface, and at least three concrete implementations would be.

    Then describe, at a high level (as if verbally at a white-board job interview):

    • The user story that you are supporting with this new “strategy”. (Write it in the form “as an x I can y so that z”.)
    • The client Java class, strategy interface, and three concrete implementations
    • The big picture of how this is an example of the strategy pattern.

    Space for each part of your answer is provided below, and on the next page.

    1. (6 pts) Write the name of your team’s webapp, and then describe your user story in form of “as an x I can y so that z”.

    (Continued on next page)

  9. Continued from previous question:

    1. (4 pts) Describe the client Java class. You don’t need to write the full Java code for it. Just a high level description is sufficient. It needs to be just enough detail so that we can understand how you are applying the strategy pattern, and no more than that.

    2. (4 pts) Describe the interface. Here, since it is only an interface, and will likely have just the signature of a single method, please do provide the entire Java code as part of your description (it should only be 4-6 lines, total.)

    (Continued on next page)

  10. Continued from previous question:

    1. (6 pts) Describe three concrete implementations of your interface. Just the name of each, and general description is sufficient. Again, we are looking only for enough detail to show that you understand the strategy pattern.

    2. (4 pts) Finally, offer a brief “big picture” explanation of how this use of the strategy pattern supports the user story that you chose. I should be able to tell from your answer how your code helps the user acheive their goal, and that you understand the strategy pattern.

End of Exam