Midterm Exam Solution - Software Engineering

ninetimesdissemblingΛογισμικό & κατασκευή λογ/κού

10 Νοε 2012 (πριν από 8 χρόνια και 8 μήνες)

2.541 εμφανίσεις

CS 160: Software Engineering

Midterm Solution

Department of Computer Science

San Jose State University


Spring 2010

Instructor: Ron Mak

www.cs.sjsu.edu/~mak

Department of Computer Science

Spring 2010: Midterm Solution

CS 160: Software Engineering

©
R. Mak

2

Question 1

1.
ABC Manufacturing has just hired a software consultant to develop
a new application to manage its widgets production facility. The
consultant tells the company’s production manager, who is an old
timer with many years of experience, to write down all the
requirements in as much detail as possible. The consultant will
then take these requirements with him to his cabin in the woods
where he can work in isolation and without interruption. He’ll return
to ABC Manufacturing in three months with the completed
application.


a.
[10 points] What problems do you see with this arrangement?



Waterfall model

applied to the entire development (only one iteration).


Requirements elicited from only a
single source
.


Lack of communication

during development.


No prototype
.

Department of Computer Science

Spring 2010: Midterm Solution

CS 160: Software Engineering

©
R. Mak

3

Question 1
(cont’d)

b.
[10 points] If you were the consultant, how would you work with ABC
Manufacturing that will increase your likelihood of success?



Elicit requirements from
multiple sources
.


Use
agile development

methodology (multiple iterations).


Create and demo
prototypes

to clarify requirements.


Constant communication
.

Department of Computer Science

Spring 2010: Midterm Solution

CS 160: Software Engineering

©
R. Mak

4

Question 2

2.
[15 points] Consider the use case that describes the edit
-
compile
-
run cycle when you develop Java code using NetBeans. Draw a
UML sequence diagram that shows the interactions among high
-
level components in this use case. (You should not need more
than 6 components.)


Department of Computer Science

Spring 2010: Midterm Solution

CS 160: Software Engineering

©
R. Mak

5

Programmer

NetBeans

Text Buffer

display errors

Java

Compiler

Java Syntax

Checker

File

System

NetBeans

Command

check source

save source

write

write .java file

edit source

Java Virtual

Machine

compile

run program

display runtime output

run

read .java file

write .class file

compile program

read .class file

Question 2
(cont’d)

Department of Computer Science

Spring 2010: Midterm Solution

CS 160: Software Engineering

©
R. Mak

6

Question 3

3.
The “forward engineering” feature of the MySQL Workbench tool
has a graphical user interface that enables you to create an entity
-
relationship (ER) diagram manually, and then the tool can
generate a physical database from the diagram automatically.
Consider this feature’s model
-
view
-
controller (MVC) architecture.


a.
[5 points] Identify the model objects.



The database tables, relationships, fields, etc.


b.
[5 points] Identify the view objects.



The GUI elements: drawings, menus, buttons, text boxes, etc.


c.
[5 points] Identify the controller objects.



The objects that interpret the user actions on the view objects in order to
modify the model objects.

Department of Computer Science

Spring 2010: Midterm Solution

CS 160: Software Engineering

©
R. Mak

7

Question 4

4.
Suppose a teaching assistant for this CS 160
class wanted to build a relational database to
keep track of the project teams. His first attempt
at the database consists of a single table, as
shown in the ER diagram.


For each of the following queries,
either

write the
SQL statement to perform the query based on
this database,
or

explain why the query would be
difficult to do.


a.
[5 points] What are the name and URL of team
Alpha’s product?



SELECT product_name, product_URL

FROM team

WHERE team_name = ‘Alpha’


Department of Computer Science

Spring 2010: Midterm Solution

CS 160: Software Engineering

©
R. Mak

8

Question 4
(cont’d)

b.
[5 points] Which students are on team Beta?



Difficult (tedious, at least) to do because of the
repeated student fields. Each first name/last name
pair would need to be listed separately in the
SELECT clause.


c.
[5 points] Which team is Mary Jones on and what
is her project grade?



Also difficult to do because the test for Mary Jones
would have to be duplicated for each student in the
row and then OR’d together.


Department of Computer Science

Spring 2010: Midterm Solution

CS 160: Software Engineering

©
R. Mak

9

Question 5

5.
Using your knowledge of this CS
160 class, normalize to 2NF the
project team database from the
previous page. (Remember that
each student on a particular
project team will receive the
same project grade.)


a.
[15 points] Represent your
normalized tables with a crow’s
feet ER diagram that shows the
table fields. You can leave off
the data types, but identify the
primary and foreign keys by
appending (PK) or (FK),
respectively, to the names of
each key. Show the
relationships of the tables to
each other.

PK

FK

PK

FK

b.
[5 points] Based on your
normalized database, write the
SQL query:


Which team is Mary Jones on
and what is her project grade?

SELECT team_name, project_grade

FROM team, student

WHERE team_id = fk_team_id

AND first_name = ‘Mary’ AND last_name = ‘Jones’

Department of Computer Science

Spring 2010: Midterm Solution

CS 160: Software Engineering

©
R. Mak

10

Question 6

6.
JDBC has both object
-
oriented and non
-
object
-
oriented features.


a.
[5 points] Briefly describe how JDBC is object
-
oriented.



JDBC uses objects to represent database connections, query statements,
result sets, etc.


b.
[5 points] Briefly describe how JDBC is not object
-
oriented.



To fetch data from the database, a program must iterate over a result set
object. The API returns the
values of individual fields

of the rows.


c.
[5 points] What are some ways to design your application to overcome
JDBC’s non
-
object
-
oriented features?



Do
object
-
relational mapping

to create JavaBeans that contain row data.


Put all the database access code in a
data access layer

to hide it from the
rest of the application.