Академический Документы
Профессиональный Документы
Культура Документы
People may come and go, but software may remain A software product is often expected to be used for an extended period of time by someone who did not write the program and who is not intimately familiar with its internal design Software may evolve New features may be added, environments may change, so initial specification may be incomplete
Waterfall Model
1 2 3 4 5 Requirements (requirements are determined) Analysis (requirements are analyzed) Design (components are designed) Implementation (components are implemented) Testing (components are assembled and tested as a whole)
4) Test
a. Unit Test b. Integration Test c. Acceptance Test
5) Installation 6) Maintenance
3) Implementation
10
11
12
13
14
Object Relations
15
16
Interfaces
The interface specifies the names, parameters, and return values of the ADT methods without specifying how the methods perform their operations and without specifying how the data is internally represented Each class that implements an interface must provide the definitions of all methods declared in the interface
17
Interfaces
You cannot instantiate an interface; that is, cant invoke new INTERFACE_NAME You can declare a variable that has an interface type and use it to reference an actual object A Java interface is a contract between the interface designer and the programmer who codes a class that implements the interface
18
19
20
do {
choice = JOptionPane.showOptionDialog( null, Select a Command, PhoneDirectory, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTIONE_MESSAGE, null, command, command[commands.length 1]); switch (choice) { case 0: doAddChangeEntry(); break; case 1: doLookupEntry(); break; case 2: doRemoveEntry(); break; case 3: case 4: doSave(): break; default: // Do nothing. } } while (choice != commands.length 1); // No parent // Prompt message // window title // Option type // Message type // Accompanying icon // Choice names (array) // Default command
21
22
23
Searches the array for the name and returns the position of the name; -1 indicates that the name was not found
Adds to the array a new entry with the given name and number
Creates a new array with twice the capacity of the current one with the same entries
24
DirectoryEntry Class
Data Field private String name private String number Constructor public DirectoryEntry(String name, String number) Method public String getName() public String getNumber() public void setNumber(String number) Attribute The name of an individual The phone number of the individual Action Create an entry with the name and the number Action Retrieves the name of an individual Retrieves the number of an individual Sets the number of an individual to the give number 25
// Read each name and number and add the entry to the array. BufferedReader in = new BufferedReader(new FileReader(new File (this.filename))) while ((name = in.readLine()) != null) { // Read name and number from successive lines. if ((number = in.readLine()) != null) { break; } // No number read, exit loop. // Add an entry for this name and number. this.add(name, number); }
26
Code Reuse
A part of program can be reused for other programs If there is a code for maintaining a phone book (adding, removing, editing, loading, and storing), some of the ideas and concepts used for the code can be used for writing a code for maintaining business cards.
27
28
29