Docsity

EECS 481 — Software Engineering Spring 2020 — Exam #2, Lecture notes of Software Engineering

Toggle sidebar
bg1
EECS 481 — Software Engineering
Spring 2020 — Exam #2
•There are seven (7) questions in this exam, each with multiple parts. Some questions
span multiple pages. If you get stuck on a question, move on and come back to it later.
•Once you download this exam, you have two (2) hours to complete and upload it. If
you encounter technical difficulties, email the staff immediately.
•This exam is open book, notes, and Internet. You may not communicate with others
while completing this exam. You can email the staff, make private Piazza posts, or
use Slack to send direct messages to staff. We will try to respond during the hours of
11AM to 11PM Eastern time on Saturday and Sunday. Any public posting on course
forums or to a third party website will result in an automatic zero.
•You will complete the exam by filling in the accompanying exam-answers.txt files.
Once complete, submit exam-answers.txt alone to the course website: https://
dijkstra.eecs.umich.edu/kleach/eecs481/shibboleth/exam2-submit.php.
•Solutions will be graded on correctness and clarity. Each problem has a relatively
simple and straightforward solution. We may deduct points if your solution is far more
complicated than necessary.
•If you leave a non-extra-credit portion of the exam blank or drawn an X through it,
you will receive one-third of the points rounded down (e.g., 4/3=1), for
that portion for not wasting time.
UM uniqname: Key Generated for kjleach.
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe

Partial preview of the text

Download EECS 481 — Software Engineering Spring 2020 — Exam #2 and more Lecture notes Software Engineering in PDF only on Docsity!

EECS 481 — Software Engineering

Spring 2020 — Exam

  • There are seven (7) questions in this exam, each with multiple parts. Some questions

span multiple pages. If you get stuck on a question, move on and come back to it later.

  • Once you download this exam, you have two (2) hours to complete and upload it. If

you encounter technical difficulties, email the staff immediately.

  • This exam is open book, notes, and Internet. You may not communicate with others

while completing this exam. You can email the staff, make private Piazza posts, or

use Slack to send direct messages to staff. We will try to respond during the hours of

11AM to 11PM Eastern time on Saturday and Sunday. Any public posting on course

forums or to a third party website will result in an automatic zero.

  • You will complete the exam by filling in the accompanying exam-answers.txt files.

Once complete, submit exam-answers.txt alone to the course website: https://

dijkstra.eecs.umich.edu/kleach/eecs481/shibboleth/exam2-submit.php.

  • Solutions will be graded on correctness and clarity. Each problem has a relatively

simple and straightforward solution. We may deduct points if your solution is far more

complicated than necessary.

  • If you leave a non-extra-credit portion of the exam blank or drawn an X through it,

you will receive one-third of the points rounded down (e.g., 4 /3 = 1), for

that portion for not wasting time.

UM uniqname: Key Generated for kjleach.

1 Delta Debugging (13 points)

The Delta Debugging (DD) algorithm makes certain assumptions about its input. It re-

quires that the interesting function be monotonic, unambiguous and consistent. Consider the

following snippet of code.

1 int macaroni ( int s ) { 2 int * x = NULL ; 3 4 x = ( int *) malloc ( s * 1024 * 1024 * 1024 * sizeof ( int )); 5 6 if ( x == NULL ) { 7 return -1; 8 } else { 9 return 0; 10 } 11 }

Say we want to minimize a test suite for this macaroni function.

malloc is a function that asks the system to allocate the specified amount of memory — it

returns a pointer if allocation is successful, and NULL if the memory cannot be allocated.

(Reminder: 1024 bytes = 1KB, 1024KB = 1MB, etc. Also, what does it mean to allocate

negative bytes?).

(a) (2pts. total) Assuming your development system has 16GB of memory available to

respond to malloc requests, 32-bit integers, that this program is run in complete iso-

lation, AND memory allocation is perfectly optimal, complete the table of test cases

and corresponding output.

Test # Input (int s) Output of macaroni?

0 3 F

1 2 F

2 -2 T

3 2048 T

4 -3 T

2 Design Patterns (14 points)

Consider a multiplayer computer game. In this game, each player controls the movement of

their character. Whenever a player moves their character, all other players see where that

player’s character moves. Your tragic developer provides the following Java code.

1 class Point { 2 public int x , y ; 3 public Point ( int _x , int _y ) { x = _x ; y = _y ;} 4 } 5 class Game { 6 Player players [32]; // 32 players 7 public startGame () { 8 for ( int i =0; i <32; i ++) 9 this - > players [ i ] = new Player (); 10 11 while ( true ) { 12 // main game loop 13 for ( int i =0; i <32; i ++) 14 players [ i ]. move ( random () , random () ); 15 16 for ( int i =0; i <32; i ++) { 17 for ( int j =0; j <32; j ++) { 18 if ( i == j ) continue ; 19 players [ i ]. updateOtherPlayer ( players [ j ]); 20 } 21 } 22 } 23 } 24 } 25 class Player { 26 public Point pos ; // position 27 public Player () { 28 // constructor 29 pos = new Point (0 ,0); 30 } 31 public void move ( int _x , int _y ) { 32 // move player to new position 33 pos = new Point ( _x , _y ); 34 } 35 public Point updateOtherPlayer ( Player p ) { 36 // update information about another player 37 Point otherPos = p. pos ; 38 this. updateGameScreen ( p , p. pos ); 39 } 40 }

You may make the following assumptions about the code.

  • random is a helper method that returns a random integer.
  • updateGameScreen is a helper method that updates one player’s view of another indi-

vidual Player’s position.

(a) (6pts.) Identify two (2) design patterns that might be useful in this program and

explain why. (One sentence each).

Publish-subscribe – multiple players waiting for information from a server; Singleton

  • one instance of game. You could also argue for MVC (with discussion about the

Player’s view and the Game instance modeling player motion) or factory (e.g., with

the Point class)

(b) (6pts.) Suppose you want to reorganize the Game.main method. Further suppose that

you add a method to Game:

1 ... ( other stuff from Game ) ... 2 public void updateAllPlayers ( Player p ) { 3 for ( int i =0; i <32; i ++) { 4 if ( players [ i ] == p ) continue ; 5 this. players [ i ]. updateOtherPlayer ( p ); 6 } 7 } 8 ... ( other stuff ) ...

If you wanted to call this method from Player.move, what change would you need to

make to Player.move? (One sentence or less).

You need to couple the Player class with Game by passing in a Game instance to the

method as well.

(c) (2pts.) In one word, what property are you increasing by making the change above?

Coupling. You’re increasing coupling between Game and Player.

Support: neural efficiency is a proxy for expertise in other domains – using it can

help objectively identify software engineering expertise. Refute: aside from ethical (we

don’t want to be like Gattaca) and practical (it may be too costly) concerns, neural

efficiency from one person to another may vary and not be comparable.

(e) (3pts.) Explain in your own words a specific scenario that might involve a multi-

language project. Use two sentences or fewer.

Answers will vary. Projects can vary from things like TensorFlow to personal projects.

1 point for vague answer (e.g., a project that needs a fast C kernel), 2 points for a

description of a project that involves multiple languages but no cross-language inter-

action, and full credit for a project that describes in detail a project where multiple

languages interact.

(f) (2pts.) Chad Spensky explained that it was important to “pro up” with various soft-

ware engineering tools. Describe what this means in one sentence.

This is an informal argument that developers should become experts at the tools they

use. Also calling back to the productivity lecture, expertise in specific tools can help

you get work done faster.

(g) (3pts.) In Jack Wadden’s guest lecture, he explained a scenario in which a difference

in a simulation versus real hardware led to a difficult defect to track down. Explain

how Delta Debugging might be used to help discern such a difference in compilation

tools.

Delta Debugging is use for test suite minimization. Wadden could have used DD to

help develop a test suite in which interestingness was defined as a difference between

simulated and physical output. A minimal test suite could have been used to find

specific locations in Verilog code that led to the difference in behavior.

Half credit for mentioning minimization, half credit for mentioning interestingness.

4 Software Engineering Narrative (15 points)

(1 pt. each) Read the following narrative. Fill in each blank with the single most specific

or appropriate corresponding concept from the answer bank. (Each blank does have

exactly one corresponding answer.) Each option can be used more than once.

A. Conditional Breakpoint B. Creational Design Pattern C. Defect D. Fault E. Fault Localization F. Feature Request G. Priority H. Profiling I. Requirements Elicitation J. Singleton Design Pattern K. Stakeholder L. Swiss Cheese Model M. Traceability N. Triage O. Watchpoint

(a) B The video streaming site BiliKan uses a single Video class to encapsulate manipulation

of multiple video formats. Each video format has an associated subclass that works

with that specific video format.

(b) C Your new intern inserts a null pointer dereference in the middle of your team’s module.

(c) D Your code compiles just fine, but running it against one test case seems to cause

accessing memory beyond the boundary of an array, leading to a crash at runtime.

(d) J The Pizza company Trionomos wants to keep track of their statistics, such as pizzas

sold, revenue to date, and number of locations in one centralized location.

(e) G In the middle of a sprint, your manager tells you to fix a bug identified in a defect

report as soon as possible.

(f) L A credit reporting company NutriFax experiences a massive data breach. Upon inves-

tigation, it was discovered that multiple failures occurred in sequence: the database did

not throttle queries, the front-end allowed requesting millions of records at once, and

the authentication mechanism allowed administrative access without valid credentials.

(g) F The developers of “Bashing Mealworms” want to add support for different colored

in-game Mealworm characters in response to player feedback.

(h) A A developer wants to stop a program’s execution when the variable x equals 5.

(i) H You insert time measurements at the beginning of each function to determine which

functions of code to optimize by reimplementing in native C.

(j) N A defect report related to the Pizza topping ”anchovies” is received. However, the

report is closed because it is deemed not reproducible.

(k) I Hannah approaches a new customer concerning their request for new pharmacy man-

agement software. Hannah prepares for interactions with this customer by reading

about prescription laws to determine the scope and costs of a pharmacy-related soft-

ware project.

(l) M The music software VeggieLoops has an individual test case for each individual require-

ment.

(m) K The printer company Cannon is considering developing software that optimally con-

serves ink in their consumer printers. However, the CEO is concerned that this will

5 Interviewing (17 points)

You are a hiring manager considering three candidates. You have given each candidate the

following prompt:

Given an array of integers of size N + 1, each integer from 1 to N is in the array

once except for one integer, which appears twice. Find the value of the integer

that appears twice. If no pair exists, report an error.

(a) (4pts.) List 4 test cases that you would expect a good candidate to provide, and why.

Answers can vary depending on generated interviewee code. We would expect to see

“normal cases” as well as corner cases (e.g., empty list, empty output, errant spaces,

etc.)

Candidate 1 provides the following code.

1 def findDuplicate ( nums ): 2 for i in range ( len ( nums )): 3 for j in range ( len ( i )): 4 # consider each pair of numbers 5 if nums [ j ] == nums [ i ]: 6 # bail on the first match 7 return nums [ i ] 8 return None

Candidate 2 provides the following code.

1 def findDuplicate ( nums ): 2 nums. sort () 3 for i in range ( len ( nums )): 4 if nums [ i ] == nums [ i + 1]: 5 return nums [ i ] 6 raise Exception ( ’ No pairing ’)

Candidate 3 provides the following code.

1 def findDuplicate ( nums ): 2 for i in range ( len ( nums )): 3 for j in range ( len ( nums )): 4 if nums [ j ] == nums [ i ]: 5 return nums [ i ] 6 return None

(b) (10pts.) In the table below, mark with a X the candidate that performed the best with

respect to each property listed and explain why briefly.

C 1 C 2 C 3 Explanation

Correctness

Error Handling

Maintainability

Runtime Complexity

Space Complexity

Answers will vary. However, in general, Candidate 1 was designed to be the most

well-documented and maintainable, Candidate 2 was designed to be best at meeting

the exact prompt, and Candidate 3 always had a defect. In general, we expect no attri-

butions to Candidate 3, while 1 would be most maintainable, but 2 handles errors the

best. Space and Runtime complexity will vary based on implementation you received.

(c) (3pts.) Support or refute the claim that you, as the interviewer, must detect and guard

against defective code from candidates. Use two sentences or fewer.

Support: You want to reject bad candidates, so you are willing to accept false negatives.

The interview is the only time the candidate has to demonstrate competence, so they

must provide correct code.

Refute: Increased tension and cognitive load from a non-indicative interview envi-

ronment may lead the candidate to make small mistake that do not represent their

typical behavior. You may be willing to forego a limited amount of correctness if it

means evaluating the candidate as a potential co-worker. In addition, you may not be

able to guard against incorrect code — can you really interpret every candidate’s code

perfectly?

pattern string Actual Expected Lines not covered

’’ ’dog dog’

False False

’ ’ ’dog dog’

False False

False False

’ 1 2 2 1 ’ ’ dog cat cat dog ’

True True

’1 1 1 1’ ’dog cat dog’

False False

Lines not covered will vary.

(b) (2pts.) Identify any defect(s) in the code above including line number(s) and how to

fix it/them. If none are present, explain why.

Answers will vary. We inserted random one-edit mutations.

(c) (3pts.) Support or refute the claim that and automated program repair tool could

easily apply to the program above with the given fault localization and test suite.

Support: one-edit mutations are readily made by APR tools.

Refute: a poor test suite may mislead fault localization (incorrect suspiciousness),

leading to incorrect or inappropriate APR results.

7 Extra Credit (1 pt each; we are tough on reading questions)

(a) (Feedback) What advice would you give to future students in this class?

u should take it lol

(b) (Feedback) What was your least favorite topic covered in the course?

The end.

(c) (Feedback) What was your most favorite topic covered in the course?

ALL OF IT.

(d) (Psychology) Explain the illusory truth effect in your own words.

repeating a lie a lot makes you believe it’s true.

(e) (Your Choice Reading) Identify any optional reading. Write a sentence about it that

convinces us that you read it critically. (Our subjective judgment applies here!).

(f) (Your Choice Reading 2) Identify any different optional reading. Write a sentence

about it that convinces us that you read it critically. (Our subjective judgment applies

here!).