Download presentation
Presentation is loading. Please wait.
1
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 10 - 1 Software Development Software Life Cycle UML Diagrams Incremental Development
2
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 10 - 2 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. Many approaches have been used over the years –Step-wise refinement –Object-oriented programming is an approach that was developed for engineering better software.
3
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 10 - 3 Software Life Cycle The sequence of stages from conception to operation of a program is called software life cycle. Five stages are –Analysis –Design –Coding Implement the detailed design into an actual program. –Testing Operation and Maintenance Program is put into use. Software maintenance accounts for approximately 70% of the cost of the software.
4
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 10 - 4 Software Life Cycle Analysis phase: –Study the problem. –Determine if a solution is possible. –Develop a requirements specification describing the features of the program. Questions to be answered –What should the program do? –Who will use the program? –Is the problem solvable? The assignment is a form of requirements specification.
5
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 10 - 5 Software Life Cycle Design phase: –Turn the requirements specification into a detailed program design. Here is where you decide how to solve the problem –Fully define all classes and objects, including how they behave and communicate between themselves. Here is where you use the UML diagrams you have been learning about –Work out a plan for the order of implementation In order to design the program, you need to understand the specification. –At the beginning of this stage you should be asking questions about anything that you don't understand.
6
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 10 - 6 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, … We'll use a subset of this language in this class. –Object diagrams –Class diagrams –State-of-memory diagrams are a variant of UML diagrams
7
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 10 - 7 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
8
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 10 - 8 Class Diagram 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
9
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 10 - 9 High-Level Class Diagram 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
10
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 10 - 10 UML Showing Inheritance Inheritance is a mechanism in OOP to design two or more entities that are different but share many common features. –Features common to all classes are defined in the superclass. –The classes that inherit common features from the superclass are called subclasses. Account Checking Savings Here are the superclass Account and its subclasses Savings and Checking.
11
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 10 - 11 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
12
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 10 - 12 Object Diagrams One box for each object Each object may have data inside it Example of a Loan object
13
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 10 - 13 Tools for UML Diagrams dia - a linux tool that allows you to draw many different kinds of diagrams –from the prompt type dia violet - a java program to create simple UML diagrams –copy violet.jar from ~tole/teaching/cs125/demo to a directory of your own –run the program using java -jar violet.jar
14
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 10 - 14 Approaches to Development Top-down –Develop the top-level classes first –create minimal classes for service objects for testing Bottom-up –develop service classes first –write test classes or main methods in the service classes for testing
15
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 10 - 15 Incremental Development Implement the program in small steps. –Each step needs to be independent of all steps that come after it. –Each step should be testable.
16
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 10 - 16 Steps in Incremental Development Read the problem statement –See if anything needs clarification –Identify major tasks Design the program –Decide how to implement each task Choose a development plan –Determine which tasks depend on other tasks Implement one task at a time –test after completing each task (unit testing) Test thoroughly after all tasks are complete
17
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 10 - 17 High-Level Steps Get the program input Compute the result Report the results Observation You can't test the input without doing some output Approaches Add extra output during development and remove it in the final version Consider programming the output first (or some of it) Interleave input/computation with output
18
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 10 - 18 Intstantiable Classes Create a class skeleton with a main method You need to create an object to do anything –Write a constructor first –create a new object in main You need output to tell if anything is happening –write the toString method –print the object you created in main Each time you add a constructor/method to the class, add code to the main method to call it and print something to see you if it worked
19
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 10 - 19 Stubs and Drivers Stub is basically a method with an empty body that replaces the finished method during early parts of the development –Methods that return values need to return a dummy value of appropriate type A driver is a program that is used to test a single class or a partial set of classes. –An instantiable class can have a main method to test itself
20
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 10 - 20 Example Suppose we want to use our Student class in a program that manages a gradebook. Classes we need –Student –Roster - contains a collection of students for a course –ManageRoster - has a console menu for manipulating the roster Possible approaches –Bottom-up –Top-down –Mixed
21
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 10 - 21 Bottom-up Write the independent class first and build up from there –You'll need some test code to make sure these classes work before you use them in other classes
22
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 10 - 22 Top-Down Create a skeleton of the main class first –add methods (or stubs) to other classes as needed
23
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 10 - 23 Javadoc comments Javadoc comments begin with /** and end with */. –put one at the top of each class –provide one for each public variable and method in the class Javadoc tags are special markers that begin with @. For example: –@author –@param - provide one for each parameter of each method –@return - describes the return value Tags should be on separate lines at the end of the appropriate javadoc comment
24
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter 10 - 24 Software Life Cycle Testing phase: –Run the program using different data sets to verify the program works properly. –Unit testing: Test classes and methods individually. –Integration testing: Test that the classes work together correctly.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.