Software Development StudyCovered So FarAssume You Already KnowTodayObject-Oriented Design Case StudyProblem SpecificationSoftware DesignDesign – Identifying ClassesSlide 9Design – State and BehaviorState – Instance VariablesSlide 12BehaviorSlide 14Behavior – Class MethodsSlide 16Design – Inheritance and InterfacesInheritanceInterfacesDesign – UML DiagramsSlide 21TestingSlide 23Slide 24Slide 25Unit TestFlow PathSlide 28Integration TestAcceptance TestTesting – Heating SimulationSoftware Development StudyFawzi EmadChau-Wen TsengDepartment of Computer ScienceUniversity of Maryland, College ParkCovered So FarSoftware life cycleObject-oriented design & programmingUnified Modeling Language (UML)Assume You Already KnowObject-oriented programming in JavaClass definitionsStateBehaviorIdentityInheritanceExtending a classAbstract classesInterfacesPolymorphismClass objectIf you need a refresher, read Chapter 3 in bookTodayCase study in OOPTestingObject-Oriented Design Case StudyProblem specificationSoftware design1. Identifying classes2. State and behavior3. Inheritance and interfaces4. UML diagramsTesting1. Unit test2. Integration test3. Acceptance testProblem SpecificationSpecification documentBuild a heating simulation that models behavior ofLiving roomThermostatFurnaceEnvironment outside roomAdvance simulation clock every 60 secondsCalculate temperature using formula (in book)Turn furnace on/off depending on room temperatureOutput temperature until simulation length reachedSoftware Design1. Identifying classes2. State and behavior3. Inheritance and interfaces4. UML diagramsDesign – Identifying ClassesFind nouns in specificationSimulationRoomThermostatFurnaceEnvironmentClockTemperatureDesign – Identifying ClassesFind nouns in specificationSimulation Entity outside programRoom Entity in programThermostat Entity in programFurnace Entity in programEnvironment Entity in programClock Entity in programTemperature State of entityDesign – State and BehaviorFind state for each classNouns in specification (not representing classes)State required for functionAdd to class as instance variablesFind behavior for each classVerbs in specificationInteractions between classesConstructors & destructorsAdd to class as methodsState – Instance VariablesEnvironmentTemperatureFurnaceOn / off stateCapacity, efficiency (from formula)RoomTemperatureArea (from formula)Reference to furnaceReference to environmentState – Instance VariablesThermostatDesired temperature settingAmount of overheating (from formula)Reference to furnace it controlsReference to room it is inClockCurrent timeInterval between ticksBehaviorFind verbs in specificationModels (behavior)Advance (clock) Calculate (temperature) Turn on/off (furnace) Output (temperature)BehaviorFind verbs in specificationModels (behavior) outside scope of classAdvance (clock) mutator for ClockCalculate (temperature) mutator for RoomTurn on/off (furnace) mutator for FurnaceOutput (temperature) mutator for RoomBehavior – Class MethodsEnvironmentDouble getTemperature()Void setTemperature(double t) FurnaceBoolean isHeating();Void setHeating(boolean onOff)RoomDouble getFloorArea()Furnace getFurnace()Environment getEnvironment()Void determineTemperatureChange()Behavior – Class MethodsThermostatRoom getRoom()Furnace getFurnace()Double getSetting()Void setSetting(double newSetting)Double overHeat()Void determineStateChange()ClockClock(int tickInterval)Design – Inheritance and InterfacesSelect inheritance and interfacesSpecialize existing classes Allow future sharing of state & behaviorInheritanceAdd GasFurnaceAdd pilot lightSpecialize existing FurnaceExampleGasFurnace extends FurnaceNew statepilotLightNew behaviorBoolean isPilotOn()Void setPilot(boolean onOff)InterfacesAdd ClockListenerUseful for simulationsAllow objects to update their state based on clockExampleInterface ClockListenerVoid preEvent(double timeInterval)Void event()Room implements ClockListenerThermostat implements ClockListenerDesign – UML DiagramsDesign – UML DiagramsTestingGoalDetect and eliminate errors in programFeedback to improve softwareSpecification changesAdd new functionalityExtremely important for success!TestingTechniquesClear box testingAllowed to examine codeAttempt to improve thoroughness of testsBlack box testingTreat program as “black box”Test behavior in response to inputsTestingStagesAlpha testTest components during developmentUsually clear box testBeta testTest in real user environmentAlways black box testAcceptanceTestingEmpirical testingTest software with selected test casesMore scalable than verificationNot guaranteed to detect all errorsSteps1. Unit test2. Integration test3. Acceptance testUnit TestTest individual units extensivelyClassesMethodsCentral part of “eXtreme Programming” (XP)Extensive unit testing during developmentDesign unit tests along with specificationApproachTest each method of classTest every possible flow path through methodFlow PathUnique execution sequence through programExample S1while (B1) {if (B2)S2elseS3}FlowsS1S1, S2S1, S3S1, S2, S2S1, S2, S3S1, S3, S2S1, S3, S3…Unit TestNot possible to test all flow pathsMany paths by combining conditionals, switchesInfinite number of paths for loopsNew paths caused by exceptionsTest coverageAlternative to flow pathEnsure each line of code testedDoes not capture all possible combinationsIntegration TestTest interaction between unitsPossible units fail when combinedMay find problems in specificationsApproachTest units togetherProceed bottom up, in increasing sizeExample test sequence1. AB, AC, AD, CD, CE2. ACD3. ABCDEBACDEAcceptance TestTest entire softwareApproachPlace software in user environmentTest software withReal-world dataReal usersTypical operating conditionsTest cases selected by usersEnsure software meets specificationsTesting – Heating SimulationUnit testsConstructors for each classMethods for each classIntegration testsTest Room / Thermostat with FurnaceTest Room / Thermostat with ClockListenerAcceptance testsRun simulations with different parametersCheck program produces correct resultsEnsure program
View Full Document