1 / 33

Hoe snel loopt iemand de 100 meter ?

Hoe snel loopt iemand de 100 meter ?. 4. Planning. Tijdsschatting Analogie & Decompostie Empirische schatting Plan 2.0 & Plan 2.1 Conclusie TicTacToe Code Hergebruik => TestCase HTML Uitvoer => polymorfisme “Undo” => Lijsten & polymorfisme. "Ontwikkel" vereisten. Vereisten

calum
Download Presentation

Hoe snel loopt iemand de 100 meter ?

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Hoe snel loopt iemand de 100 meter ? Planning

  2. 4. Planning • Tijdsschatting • Analogie & Decompostie • Empirische schatting • Plan 2.0 & Plan 2.1 • Conclusie • TicTacToe • Code Hergebruik=> TestCase • HTML Uitvoer=> polymorfisme • “Undo”=> Lijsten & polymorfisme Planning

  3. "Ontwikkel" vereisten • Vereisten • Betrouwbaarheid • Aanpasbaarheid • Planning • Technieken • Testen + Contracten • Objectgericht ontwerp • Tijdsschatting Planning

  4. Schatting door analogie Analogie • Schatting = tijd gelijkaardig project • Wanneer gelijkaardig ? • Zelfde probleemdomein • Zelfde mensen • Zelfde technologie Empirisch gespendeerde tijd voorbije projecten dient als basis voor schatting volgende Planning

  5. Empirische schatting (project) Schat totale duur van project op basis van vorige projecten y = a x b (b ±= 1) Y Legende Ontwikkeltijd = Voorbij = Prognose X Grootte project Planning

  6. Schatting door decompositie Decompositie • Schatting = tijd componenten + integratiekost • Tijd componenten ? • cfr. opgeleverde componenten • Integratiekost ? • constant (mits testen en OO) Empirisch gespendeerde tijd eerste componenten dient als basis voor schatting volgende Planning

  7. Y X Empirische schatting (component) Schat duur van één component op basis van opgeleverde componenten y = m x Legende Ontwikkeltijd component = Opgeleverd = Prognose Grootte component Planning

  8. x = Grootte Component ? # stappen + #uitzonderingenin use case y = Ontwikkellingstijd ? Zie tijdsbladen Grootte en Tijd vergelijking benaderende rechte y = mx Na oplevering n componenten: (xn, yn) => m = ∑ yn / ∑ xn Schatting yn+1 voor grootte xn+1 => yn+1 = m.xn+1 Planning

  9. Vuistregel Empirische schatten is de basis voor een realistische planning. • Waarom ? • Betere controle over aanpassingen aan de planning • Hoe ? • Hou tijdsbladen nauwkeurig bij • Maak prognose op basis van gespendeerde werk in het verleden Planning

  10. play player Use Case Grootte • Use Case 1: play • … • Steps • 1. Two players start up a game(First is "O"; other is "X") • 2. WHILE game not done • 2.1 Current player makes move • 2.2 Switch current player • 3. Anounce winner • Exceptions • 2.1. [Illegal Move] System issues a warning=> continue from step 2.1 #stappen = 5 #uitzond. = 1 grootte = 6 Planning

  11. Voorbeelden Zie voorbeelden in PlanTmpl20 & PlanTmpl21 Planning

  12. Conclusie • Betrouwbare prognoses zijn belangrijk • Hou tijdsbladen nauwkeurig bij ! • Schatten impliceert fouten • Voorzie een redelijke marge • Vertrouw niet blindelings op de cijfertjes Planning

  13. TicTacToeTest setUp() tearDown() init() fail(msg: ARRAY OF CHAR) should(b: BOOLEAN, msg: ARRAY OF CHAR): BOOLEAN shouldNot(b: BOOLEAN, msg: ARRAY OF CHAR): BOOLEAN compareFiles(fileName1, fileName2: ARRAY OF CHAR): BOOLEAN testBasicPlayer(verbose: BOOLEAN): BOOLEAN testLegalMoves(verbose: BOOLEAN): BOOLEAN testRealGame(verbose: BOOLEAN): BOOLEAN testOutputGame(verbose: BOOLEAN): BOOLEAN Code Hergebruik • TicTacToeTest is groot • code leesbaarheid • hergebruik ? copy + delete + insert Aanpasbaarheid :( Planning

  14. UnitTest TicTacToeTest setUp() tearDown() init() fail(msg: ARRAY OF CHAR) should(b: BOOLEAN, msg: ARRAY OF CHAR): BOOLEAN shouldNot(b: BOOLEAN, msg: ARRAY OF CHAR): BOOLEAN compareFiles(fileName1, fileName2: ARRAY OF CHAR): BOOLEAN setUp() tearDown() init() testBasicPlayer(verbose: BOOLEAN): BOOLEAN testLegalMoves(verbose: BOOLEAN): BOOLEAN testRealGame(verbose: BOOLEAN): BOOLEAN testOutputGame(verbose: BOOLEAN): BOOLEAN Code Hergebruik • UnitTest is superklasse • bevat algemene code • hergebruik ? subklasse per te testen component/klasse • TicTacToeTest is subklasse • erft algemene code • overschrijft setup, init & teardown • bevat alleen relevante code Planning

  15. Vuistregel “Hollywood Principle” wijroepenjouw op als we je nodighebben • Waarom ? • Uitbreiding van bibliotheken via subklasses • Hoe ? • Superklasse in bibliotheeklegt protocol van oproepen vast • Subklassenkunnengedraguitbreiden Planning

  16. UnitTest setUp(testCase: ARRAY OF CHAR) run() tearDown() should (…): BOOLEAN shouldNot (…): BOOLEAN GenerischUnittest Protocol objectunder test :UnitTest setUp("testXXX") NEW(); init(); testXXXX() Evaluatie Criteria Obj. Collaboratie run() xxx1stStimulus shouldNot(xxx1stObservation) xxx2ndStimulus should(xxx2ndObservation) tearDown() Betrouwbaarheid

  17. Vuistregel Klassen die vaakherbruiktwordenhebbenpreciesecontracten • Waarom ? • Betere betrouwbaarheid door precieze beschrijving interface • Hoe ? • Leg de “normale” volgorde van oproepen vast • Specifieer volgorde via de respectievelijke pre- en postcondities Planning

  18. Initialized Setup Init() Run() SetUp() Running TornDown TearDown() Oproepvolgorde voor “UnitTest” Planning

  19. Contracten voor “UnitTest” PROCEDURE (aTest : UnitTest) Init; (* postcondition (120): aTest^.IsInitialized() *) (* postcondition (120): ~ aTest^.IsSetup() *) (* postcondition (120): ~ aTest^.IsRunning() *) (* postcondition (120): aTest^.IsTornDown() *) PROCEDURE (aTest : UnitTest) SetUp (testCase: ARRAY OF CHAR); (* precondition (100): aTest^.IsInitialized() *) (* precondition (100): aTest^.IsTornDown() *) (* precondition (100): LEN(testCase) < MaxTestCaseLength *) (* postcondition (120): aTest^.IsSetup() *) (* postcondition (120): ~ aTest^.IsTornDown() *) PROCEDURE (aTest : UnitTest) Run; (* precondition (100): aTest^.IsInitialized() *) (* precondition (100): aTest^.IsSetup() *) (* postcondition (120): ~ aTest^.IsSetup() *) (* postcondition (120): aTest^.IsRunning() *) PROCEDURE (aTest : UnitTest) TearDown; (* precondition (100): aTest^.IsInitialized() *) (* precondition (100): aTest^.IsRunning() *) (* postcondition (120): ~ aTest^.IsRunning() *) (* postcondition (120): aTest^.IsTornDown() *) Planning

  20. Vuistregel Schrijf testcode als subklasse(n) van “UnitTest” • Waarom ? • Betere onderhoudbaarheid van de testcode • Hoe ? • Maak een subklasse van “UnitTest” per te testen component • Overschrijf Init(), SetUp(), TearDown(), Run () Planning

  21. HTML Uitvoer (TTT16b) play • Use Case 3: play HTML output • Extension of use case 1 • Steps • use case 1 + additional steps • afer 2.2 • 2.3 write game on HTML (table) • during 3 • 3 write winner on HTML text player <<extends>> play HTML output (Erg gelijkaardig aan use case 2) => inheritance & polymorfisme ? Planning

  22. PROCEDURE (aTicTacToe: TicTacToe) writeHTMLOn* (VAR w: Texts.Writer); … BEGIN Texts.WriteString(w, "<P>"); Texts.WriteString(w, "TicTacToe game after move "); Texts.WriteInt(w, aTicTacToe.nrOfMoves, 0); Texts.WriteString(w, "</P>");Texts.WriteLn(w); Texts.WriteString(w, "<TABLE BORDER>");Texts.WriteLn(w); FOR i := 0 TO 2 DO Texts.WriteString(w, " <TR>");Texts.WriteLn(w); FOR j := 0 TO 2 DO Texts.WriteString(w, " <TD>"); … END; … "Ongeveer" gelijk aan writeOn => duplicatie Planning

  23. PROCEDURE (aTest: TicTacToeTest) testOutputGame* (… writeHTML: BOOLEAN): BOOLEAN; … IF writeHTML THEN Texts.WriteString(w, "<HTML>");Texts.WriteLn(w); Texts.WriteString(w, "<HEAD>");Texts.WriteLn(w); … END; WHILE aTest.aGame.notDone() DO aTest.aGame.doMove(); IF writeHTML THEN aTest.aGame.writeHTMLOn(w); ELSE aTest.aGame.writeOn(w); END; END; IF writeHTML THEN Texts.WriteString(w, "</BODY></HTML>");Texts.WriteLn(w); END; … => complexeconditionelelogica Planning

  24. Vuistregel Vermijd code duplicatie & complexe logica • Refactor: • code duplicatie: gelijkaardige code in de superklasse; verschillen in subklassen • complexe logica: normaal geval in de superklasse; speciale gevallen in de subklassen Planning

  25. TicTacToe TicTacToeTest writeOn() writeHTMLOn() testOutputGame() Splits Klassen (TTT16) Evaluatie Criteria printobjecten/iterators TicTacToeOutput TicTacToe TicTacToeOutput startPage() endPage() startBoard() endBoard() startRow(row: CHAR) endRow() boardLocation(row, column, marker: CHAR) TicTacToeTest TicTacToeHTMLOutput Planning

  26. PROCEDURE (aTest: TicTacToeTest) testOutputGame* (… writeHTML: BOOLEAN): BOOLEAN; … Texts.OpenWriter(w); output.init (); output.startPage(w); WHILE aTest.aGame.notDone() DO aTest.aGame.doMove(); aTest.aGame.writeOn(w, output) END; output.endPage(w); complexecondities=> polymorfisme Planning

  27. PROCEDURE (aTicTacToe: TicTacToe) writeOn* (VAR w: Texts.Writer; output: TicTacToeOutput.TicTacToeOutput); BEGIN output.startSentences(w); Texts.WriteString(w, "TicTacToe game after move "); Texts.WriteInt(w, aTicTacToe.nrOfMoves, 0); output.endSentences(w); output.startBoard(w); FOR i := 0 TO 2 DO output.startRow(w, CHR(ORD("1") + i)); FOR j := 0 TO 2 DO output.boardLocation(…); END; output.endRow(w); END; output.endBoard(w); extra parameter controleert verschil verschillen in gedupliceerde code => polymorfisme Planning

  28. “Undo” play • Use Case 4: play with undo option • Extension of use case 1 • Steps • use case 1 + additional steps • afer 2.1 • 2.1.1 current player “undo” move • 2.1.2 goto 2 (restart while loop) player <<extends>> play with undo option Planning

  29. “Undo” Algoritme ? • Hou een lijst bij met verloop spelstatus TicTacToeData* = RECORD (OOLists.NodeDesc) nrOfMoves: INTEGER; board: ARRAY 3, 3 OF CHAR; players: ARRAY 2 OF Player; lastCol, lastRow, lastMark : CHAR; theWinner: Player; END; Herbruik bestaande code Maar … “Klassen die vaak herbruikt worden hebben preciese contracten” Planning

  30. Contracten voor “OOLists” ? PROCEDURE (l : List) Init (); PROCEDURE (l : List) LocateFirst (); PROCEDURE (l : List) LocateLast (); PROCEDURE (l : List) LocateNode (n: Node); PROCEDURE (l : List) LocatePrev (); PROCEDURE (l : List) LocateNext (); PROCEDURE (l : List) InsertBefore (new: Node); PROCEDURE (l : List) InsertAfter (new: Node); PROCEDURE (l : List) Delete (); PROCEDURE (l : List) GetNode (): Node; PROCEDURE (l : List) Enumerate (P: NodeProc); PROCEDURE (n : Node) NodeInfo (); Contracten ? Moeilijk want interface zonder predicaten Planning

  31. “Lijst” met predicaten PROCEDURE (l : List) Init (); (* postcondition (120): l^.IsInitialized() *) PROCEDURE (l : List) Includes (n: Node): BOOLEAN; (* precondition (100): l^.IsInitialized() *) PROCEDURE (l : List) Insert (new: Node); (* precondition (100): l^.IsInitialized() *) (* postcondition (120): l^.Includes(new) *) PROCEDURE (l : List) Delete (old: Node); (* precondition (100): l^.IsInitialized() *) (* postcondition (120): ~ l^.Includes(new) *) Evaluatie Criteria Reuse (lijsten) Contracten ? Makkelijker want interface met veel predicaten Planning

  32. Vuistregel Prefereer een interface met predicaten • Waarom ? • Betere betrouwbaarheid door eenvoudige contracten • Hoe ? • Specifieer predicaten voor hoofdfunctionaliteit component • Roep predicaten op in pre- en post-condities Planning

  33. Vuistregels Testen • Schrijftestcodealssubklasse(n) van “UnitTest” Ontwerpen • Vermijd code duplicatie & complexelogica • “Hollywood Principle” – wijroepenjouw op als we je nodighebben • Klassendie vaakherbruiktwordenhebbenpreciesecontracten • Prefereereen interface met predicaten Plannen • Empirischeschatten is de basis vooreenrealistische planning Planning

More Related