software development study fawzi emad chau-wen tseng department of computer science university of...
Post on 20-Dec-2015
216 views
TRANSCRIPT
![Page 1: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/1.jpg)
Software Development Study
Fawzi Emad
Chau-Wen Tseng
Department of Computer Science
University of Maryland, College Park
![Page 2: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/2.jpg)
Covered So Far
Software life cycle
Object-oriented design & programming
Unified Modeling Language (UML)
![Page 3: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/3.jpg)
Assume You Already Know
Object-oriented programming in Java
Class definitionsState
Behavior
Identity
InheritanceExtending a class
Abstract classes
Interfaces
Polymorphism
Class object
If you need a refresher, read Chapter 3 in book
![Page 4: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/4.jpg)
Today
Case study in OOP
Testing
![Page 5: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/5.jpg)
Object-Oriented Design Case Study
Problem specification
Software design1. Identifying classes
2. State and behavior
3. Inheritance and interfaces
4. UML diagrams
Testing1. Unit test
2. Integration test
3. Acceptance test
![Page 6: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/6.jpg)
Problem Specification
Specification documentBuild a heating simulation that models behavior of
Living room
Thermostat
Furnace
Environment outside room
Advance simulation clock every 60 seconds
Calculate temperature using formula (in book)
Turn furnace on/off depending on room temperature
Output temperature until simulation length reached
![Page 7: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/7.jpg)
Software Design
1. Identifying classes
2. State and behavior
3. Inheritance and interfaces
4. UML diagrams
![Page 8: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/8.jpg)
Design – Identifying Classes
Find nouns in specificationSimulation
Room
Thermostat
Furnace
Environment
Clock
Temperature
![Page 9: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/9.jpg)
Design – Identifying Classes
Find nouns in specificationSimulation Entity outside program
Room Entity in program
Thermostat Entity in program
Furnace Entity in program
Environment Entity in program
Clock Entity in program
Temperature State of entity
![Page 10: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/10.jpg)
Design – State and Behavior
Find state for each classNouns in specification (not representing classes)
State required for function
Add to class as instance variables
Find behavior for each classVerbs in specification
Interactions between classes
Constructors & destructors
Add to class as methods
![Page 11: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/11.jpg)
State – Instance Variables
EnvironmentTemperature
FurnaceOn / off state
Capacity, efficiency (from formula)
RoomTemperature
Area (from formula)
Reference to furnace
Reference to environment
![Page 12: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/12.jpg)
State – Instance Variables
ThermostatDesired temperature setting
Amount of overheating (from formula)
Reference to furnace it controls
Reference to room it is in
ClockCurrent time
Interval between ticks
![Page 13: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/13.jpg)
Behavior
Find verbs in specificationModels (behavior)
Advance (clock)
Calculate (temperature)
Turn on/off (furnace)
Output (temperature)
![Page 14: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/14.jpg)
Behavior
Find verbs in specificationModels (behavior) outside scope of class
Advance (clock) mutator for Clock
Calculate (temperature) mutator for Room
Turn on/off (furnace) mutator for Furnace
Output (temperature) mutator for Room
![Page 15: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/15.jpg)
Behavior – Class Methods
EnvironmentDouble getTemperature()
Void setTemperature(double t)
FurnaceBoolean isHeating();
Void setHeating(boolean onOff)
RoomDouble getFloorArea()
Furnace getFurnace()
Environment getEnvironment()
Void determineTemperatureChange()
![Page 16: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/16.jpg)
Behavior – Class Methods
ThermostatRoom getRoom()
Furnace getFurnace()
Double getSetting()
Void setSetting(double newSetting)
Double overHeat()
Void determineStateChange()
ClockClock(int tickInterval)
![Page 17: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/17.jpg)
Design – Inheritance and Interfaces
Select inheritance and interfacesSpecialize existing classes
Allow future sharing of state & behavior
![Page 18: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/18.jpg)
Inheritance
Add GasFurnaceAdd pilot light
Specialize existing Furnace
ExampleGasFurnace extends Furnace
New state
pilotLight
New behavior
Boolean isPilotOn()
Void setPilot(boolean onOff)
![Page 19: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/19.jpg)
Interfaces
Add ClockListenerUseful for simulations
Allow objects to update their state based on clock
ExampleInterface ClockListener
Void preEvent(double timeInterval)
Void event()
Room implements ClockListener
Thermostat implements ClockListener
![Page 20: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/20.jpg)
Design – UML Diagrams
![Page 21: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/21.jpg)
Design – UML Diagrams
![Page 22: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/22.jpg)
Testing
GoalDetect and eliminate errors in program
Feedback to improve software
Specification changes
Add new functionality
Extremely important for success!
![Page 23: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/23.jpg)
Testing
TechniquesClear box testing
Allowed to examine code
Attempt to improve thoroughness of tests
Black box testing
Treat program as “black box”
Test behavior in response to inputs
![Page 24: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/24.jpg)
Testing
StagesAlpha test
Test components during development
Usually clear box test
Beta test
Test in real user environment
Always black box test
Acceptance
![Page 25: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/25.jpg)
Testing
Empirical testingTest software with selected test cases
More scalable than verification
Not guaranteed to detect all errors
Steps1. Unit test
2. Integration test
3. Acceptance test
![Page 26: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/26.jpg)
Unit Test
Test individual units extensivelyClasses
Methods
Central part of “eXtreme Programming” (XP)Extensive unit testing during development
Design unit tests along with specification
ApproachTest each method of class
Test every possible flow path through method
![Page 27: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/27.jpg)
Flow Path
Unique execution sequence through program
Example S1
while (B1) {
if (B2)
S2
else
S3
}
FlowsS1
S1, S2
S1, S3
S1, S2, S2
S1, S2, S3
S1, S3, S2
S1, S3, S3
…
![Page 28: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/28.jpg)
Unit Test
Not possible to test all flow pathsMany paths by combining conditionals, switches
Infinite number of paths for loops
New paths caused by exceptions
Test coverageAlternative to flow path
Ensure each line of code tested
Does not capture all possible combinations
![Page 29: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/29.jpg)
Integration Test
Test interaction between unitsPossible units fail when combined
May find problems in specifications
ApproachTest units together
Proceed bottom up, in increasing size
Example test sequence1. AB, AC, AD, CD, CE
2. ACD
3. ABCDE
B
AC
D E
![Page 30: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/30.jpg)
Acceptance Test
Test entire software
ApproachPlace software in user environment
Test software with
Real-world data
Real users
Typical operating conditions
Test cases selected by users
Ensure software meets specifications
![Page 31: Software Development Study Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d485503460f94a23d3b/html5/thumbnails/31.jpg)
Testing – Heating Simulation
Unit testsConstructors for each class
Methods for each class
Integration testsTest Room / Thermostat with Furnace
Test Room / Thermostat with ClockListener
Acceptance testsRun simulations with different parameters
Check program produces correct results
Ensure program terminates