Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 160: Software Engineering October 15 Class Meeting

Similar presentations


Presentation on theme: "CS 160: Software Engineering October 15 Class Meeting"— Presentation transcript:

1 CS 160: Software Engineering October 15 Class Meeting
Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak

2 Midterm Question 1 Briefly discuss how each of the following software engineering techniques, technologies, and methodologies deal with the challenges of complexity and change. Model-view-controller (MVC) architecture complexity Break a GUI application into three coherent, loosely-coupled parts. Enable parallel development. change Changes to one part won’t affect the other parts.

3 Midterm Question 1, cont’d
Agile programming complexity Break development into multiple short iterations. Each iteration has design, code, and test. Always build on already working code. change Not the old waterfall model. Able to handle design and requirements changes.

4 Midterm Question 1, cont’d
Client-server architecture complexity Break a web application into three coherent, loosely-coupled parts. Enable parallel development. change Changes to one part won’t affect the other parts.

5 Midterm Question 1, cont’d
Data access layer complexity Encapsulate database connection, JDBC, etc. from the rest of the application. Object-relational mapping. change Isolate changes in the application code and in the database structure from each other.

6 Midterm Question 1, cont’d
Database table normalization complexity Eliminate multi-valued fields, repeating fields. Make tables coherent. change Easier to modify tables via insert, delete, and update operations.

7 Midterm Question 2 You are going to develop a new version of the online class registration system that you use to sign up for classes each semester. List seven (7) functional requirements. Students shall log in securely with their student IDs. System shall access the SJSU courses database. Administrator shall be able to add, delete, modify classes. Students shall add and drop displayed classes. System shall check course prerequisites. System shall check for time conflicts. System shall maintain wait lists.

8 Midterm Question 2, cont’d
List three (3) nonfunctional requirements. System shall be web-based. System shall be secure from hackers. System shall respond within 1 second.

9 Midterm Question 2, cont’d
Draw a UML use case diagram that shows at least two (2) actors and five (5) use cases. Start up system Shut down system Update classes Add class Drop class admin database student

10 Midterm Question 3 You are going to use Java on the server to implement the class registration system in Question 2. Briefly name and describe three (3) servlets. LogInStudent Log in a student securely using the student’s ID. AddClass Student adds a class. DropClass Student drops a class.

11 Midterm Question 3, cont’d
Briefly name and describe three (3) JSPs. LogInPage Displays the log in form. ClassListPage Display the list of classes the student can choose from. SchedulePage Display a student’s class schedule.

12 Midterm Question 3, cont’d
Briefly name and describe four (4) JavaBeans. Class A class that a student can take. A prerequisite class Student A student. Admin An administrator. Schedule A student’s class schedule

13 Midterm Question 4 Our example school database needs to support team teaching, where more than one instructor can teach a class. Draw an ER diagram. PK FK FK FK PK PK PK FK FK FK

14 Midterm Question 4, cont’d
Write the Java method that uses JDBC and prints the results of the query: CommonClasses(int teacherId_1, int teacherId_2) Given two teachers, which classes do they teach in common?

15 Midterm Question 4, cont’d
The 10-point description: We can assume the method can be called multiple times, so we should use a prepared statement. The prepared statement uses a teacher ID to make the query that returns the classes taught by that teacher. We can also assume that we’ve already defined a Klass JavaBean to represent a class, and we’ll use object-relational mapping to put the returned Klass objects into an array list. We’ll use the prepared statement to generate two array lists of Klass objects, one array per teacher. Then we’ll use Java to find and print the common classes.

16 Midterm Question 4, cont’d
The 15-point solution: private static String CLASSES_OF = "SELECT code, subject " + "FROM class, teacher_class " + "WHERE teacher_id = ? " + "AND code = class_code”; private static Connection conn; private static PreparedStatement ps1; conn = DriverManager.getConnection (DB_URL, USERNAME, PASSWORD); ps1 = conn.prepareStatement(CLASSES_OF);

17 Midterm Question 4, cont’d
private static ArrayList<Klass> classesOf(int id) throws SQLException { ArrayList<Klass> klasses = new ArrayList<>(); ps1.setInt(1, id); ResultSet rs = ps1.executeQuery(); while (rs.next()) { Klass klass = new Klass(rs.getInt("code"), rs.getString("subject")); klasses.add(klass); } return klasses; Object-relational mapping. Return an array list of classes taught by the teacher.

18 Midterm Question 4, cont’d
private static void commonClasses1(int teacherId_1, int teacherId_2) throws SQLException { ArrayList<Klass> klasses_1 = classesOf(teacherId_1); ArrayList<Klass> klasses_2 = classesOf(teacherId_2); ArrayList<Klass> common = new ArrayList<>(); for (Klass k1 : klasses_1) { for (Klass k2 : klasses_2) { if (k1.getCode() == k2.getCode()) { common.add(k1); } printCommon(common, teacherId_1, teacherId_2); Array list of common classes.

19 Midterm Question 4, cont’d
An alternate solution Requires a bit more advanced SQL. private static String COMMON_CLASSES = "SELECT code, subject " + "FROM teacher_class tc1, teacher_class tc2, class " + "WHERE tc1.teacher_id = ? AND tc2.teacher_id = ? " + "AND tc1.class_code = tc2.class_code " + "AND tc1.class_code = class.code " + "ORDER BY class.code"; private static PreparedStatement ps2; ps2 = conn.prepareStatement(COMMON_CLASSES);

20 Midterm Question 4, cont’d
private static void commonClasses2(int teacherId_1, int teacherId_2) throws SQLException { ps2.setInt(1, teacherId_1); ps2.setInt(2, teacherId_2); ResultSet rs = ps2.executeQuery(); ArrayList<Klass> common = new ArrayList<>(); while (rs.next()) { Klass klass = new Klass(rs.getInt("code"), rs.getString("subject")); common.add(klass); } printCommon(common, teacherId_1, teacherId_2); Array list of common classes.

21 Managing Expectations
Estimation How long will tasks take, or how many resources will they consume. Should be an unbiased, analytical process. Goal is accuracy, not to seek a particular result. Project planning A biased, goal-seeking process. Goal is to achieve specific outcomes. _

22 Managing Expectations, cont’d
Estimates form the foundation for plans. But plans don’t have to be the same as estimates. Combining estimating and planning activities leads to bad estimates and poor plans. A large gap between estimates and planning targets results in a high risk project. _

23 Estimates, Targets, and Commitments
An all-too-familiar scenario: Product manager: We need to demo these features at a trade show in 3 months. [target] How long will it take? Project lead: I estimate it will us take 5 months. Manager: Wrong answer! Try again. Lead: OK, in 3 months, we can have the highest priority features done. [commitment] Moral: When you’re asked for an estimate, determine whether you’re really being told to make a commitment to meet a target.

24 Primary Purpose of Software Estimation
Determine whether a project’s targets are realistic enough to allow the project to be controlled to meet them. Good estimates are usually possible if the initial targets and the initial estimates are within 20% of each other. _

25 “Good” Estimates Estimates don’t need to be perfectly accurate as much as they need to be useful. “A good estimate is an estimate that provides a clear enough view of the project reality to allow the project leadership to make good decisions about how to control the project to hit its targets.” Steve McConnell, Software Estimation

26 Time Unit Inflation of Estimates
Time unit inflation: hours → days → weeks → months → years “It should take me two hours to do this.” Reality: It will take two days. _

27 Estimation Techniques
Complex mathematical formulas Best for the very largest projects. Done by professional estimators. History and analogy How long did similar tasks take in the past? Expert opinions But do you have similar skills as the experts?

28 Estimation Techniques
Off-the-cuff “guesstimates” Based on personal experience. The smaller the task, the more accurate the estimate. _


Download ppt "CS 160: Software Engineering October 15 Class Meeting"

Similar presentations


Ads by Google