Presentation is loading. Please wait.

Presentation is loading. Please wait.

©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 1 Software Engineering Software Development Process.

Similar presentations


Presentation on theme: "©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 1 Software Engineering Software Development Process."— Presentation transcript:

1 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 1 Software Engineering Software Development Process Incremental Development Monogram program

2 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 2 Program Development Process Design the program Use a text editor (vim) to write a java file vim MyClass.java Compile the java code to create a class file javac MyClass.java Run the program javac MyClass Create the documentation javadoc MyClass.java

3 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 3 Software Engineering Much like building a skyscraper, we need a disciplined approach in developing complex software applications. Software engineering is the application of a systematic and disciplined approach to the development, testing, and maintenance of a program.

4 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 4 Software Life Cycle The sequence of stages from conception to operation of a program is called software life cycle. –Analysis Define the problem –Design Work out a solution Here's where you use UML diagrams –Coding –Testing –Operation and Maintenance

5 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 5 Analysis What should the program do? Who will use the program? Is the problem solvable?

6 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 6 Design This is where you decide how to implement a program –What classes do you need? –Which classes do you need to write? –What should the data and methods for each class be? –Define algorithms for various operations –Work out a plan for the order of implementation

7 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 7 UML Diagrams UML is a graphical language It can be used to model various aspects of a program –Use class diagrams to model the structure of the application –Use object diagrams to provide a snapshot of what is happening when a program runs –Other types of diagrams model requirements, program state, testing, …

8 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 8 Class Diagram Used to –Show the details of one or more classes data, methods –Show how different classes are related within a program inheritance (is-a), aggregation (has-a), using –Illustrate an inheritance hierarchy Class diagrams are static Class diagrams illustrate the structure of an application

9 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 9 Generic class diagram –name of class –list names of class and instance data values –list methods with parameters and return types Example class diagram Contact class represents a person with information needed in an address book

10 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 10 The Structure of an Application Use a box for each class Use lines to show relationships –Arrow for inheritance –Line with diamond for aggregation (has-a) –Dotted line for uses

11 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 11 Inheritance Hierarchy An example of inheritance hierarchy among different types of students. Student Graduate Undergrad Commuting Law Resident Masters Doctoral

12 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 12 Object Diagrams Used to illustrate the state of a program at different times while it is running We will use a kind of object diagrams called state- of-memory diagrams to illustrate how Java uses memory for storing information

13 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 13 Object Diagrams One box for each object Each object may have data inside it Example of a Loan object

14 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 14 Problem Statement Problem statement: Write a program that asks for the user’s first, middle, and last names and replies with their initials. Example: input: Andrew Lloyd Weber output: ALW

15 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 15 Overall Plan Identify the major tasks the program has to perform. We need to know what to develop before we develop! Tasks: –Get the user’s first, middle, and last names –Extract the initials and create the monogram –Output the monogram

16 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 16 Development Steps We will develop this program in two steps: –Start with the program template and add code to get input 1.Add code to compute and display the monogram

17 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 17 Step 1 Design The program specification states “get the user’s name” but doesn’t say how. We will consider “how” in the Step 1 design We will use JOptionPane for input Input Style Choice #1 Input first, middle, and last names separately Input Style Choice #2 Input the full name at once We choose Style #2 because it is easier and quicker for the user to enter the information

18 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 18 Step 1 Code /* Chapter 2 Sample Program: Displays the Monogram File: Step1/Ch2Monogram.java */ import javax.swing.*; class Ch2Monogram { public static void main (String[ ] args) { String name; name = JOptionPane.showInputDialog(null, "Enter your full name (first, middle, last):“); JOptionPane.showMessageDialog(null, name); }

19 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 19 Step 1 Test In the testing phase, we run the program and verify that –we can enter the name –the name we enter is displayed correctly

20 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 20 Step 2 Design Our programming skills are limited, so we will make the following assumptions: –input string contains first, middle, and last names –first, middle, and last names are separated by single blank spaces Example John Quincy Adams(okay) John Kennedy(not okay) Harrison, William Henry (not okay)

21 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 21 Step 2 Design (cont’d) Given the valid input, we can compute the monogram by –breaking the input name into first, middle, and last –extracting the first character from them –concatenating three first characters “Aaron Ben Cosner” “Aaron” “Ben Cosner” “Ben” “Cosner” “ABC”

22 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 22 Step 2 Code /* Chapter 2 Sample Program: Displays the Monogram File: Step 2/Ch2MonogramStep2.java */ import javax.swing.*; class Ch2Monogram { public static void main (String[ ] args) { String name, first, middle, last, space, monogram; space = " “; //Input the full name name = JOptionPane.showInputDialog(null, "Enter your full name (first, middle, last):“ );

23 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 23 Step 2 Code (cont’d) //Extract first, middle, and last names first = name.substring(0, name.indexOf(space)); name = name.substring(name.indexOf(space)+1, name.length()); middle = name.substring(0, name.indexOf(space)); last = name.substring(name.indexOf(space)+1, name.length()); //Compute the monogram monogram = first.substring(0, 1) + middle.substring(0, 1) + last.substring(0,1); //Output the result JOptionPane.showMessageDialog(null, "Your monogram is " + monogram); }

24 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 24 Step 2 Test In the testing phase, we run the program and verify that, for all valid input values, correct monograms are displayed. We run the program numerous times. Seeing one correct answer is not enough. We have to try out many different types of (valid) input values.

25 ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 25 Program Review The work of a programmer is not done yet. Once the working program is developed, we perform a critical review and see if there are any missing features or possible improvements One suggestion –Improve the initial prompt so the user knows the valid input format requires single spaces between the first, middle, and last names


Download ppt "©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 1 - 1 Software Engineering Software Development Process."

Similar presentations


Ads by Google