Robo Software Engineering software engineering example exercise David
Robo – Software Engineering …software engineering example exercise. . . David Davenport Computer Eng. Dept. , Bilkent University Ankara - Turkey. email: david@bilkent. edu. tr
House Problem Who has attempted it?
Robo – House Problem (1) n Specify pieces & order Pre-cond. Post-cond. 250 x 250 2 roof 50 x 50 250 1 100 x 50 main
Robo – House Problem (2) n Then solve pieces… Pre-cond. Post-cond. 1 7 3 5 window door main walls main d walls d movetoleftwin d window d movetorightwin d window d movetodoor d movetoendpoint 2 4 6 150 x 25 150 movetoleftwin movetorightwin 150 x 75 movetodoor
Software Engineering Exercise Form teams, implement, then reflect!
Pre-cond. Basic Pieces… Post-cond. (2 a + 2 b) movetoleft topright (b) base (a) (2 b) (a) 45 diamond (a) toprightbottom topleft (b) (a) (a) lefttop moveup movedown side
Composite Pieces… bc ( a, b) d side( b) x a slice( b, 12, 10) d side( b) slicetop ( a, b) d d movetoleft( a, b) topleft( b) holder( 100, a, a) topright( a, b) slice ( a, b, c) d d base( b, c) moveup( a) slicetop( b, c) movedown( a) holder ( a, b, c) d lefttop( a, b) d diamond( c) d toprightbottom( a, b)
Software Engineering Exercise The overall design!
Birthday Cake Design
Birthday Cake Design 1 2 // birthdaycake d Rect(200, 450) //cake body d tofirstcandle d candles 3 tofirstcandle
To First Candle tofirstcandle // tofirstcandle p f(200) r(90) f(50) l(90) p
Candles // candles x 4 candle
// candle Candle d d Rect(200, 50) // candle body candlebodytoflame Rect(40, 40) // candle flametonextcandle // candlebodytoflame 1 2 3 4 p f(200) r(90) f(25) l(135) p // flametonextcandle p r(135) f(25) r(90) f(200) l(90) f(50) l(90) p
SUMMARY • Advantages of TDSD • The TDSD methodology
Relating Design & Code n n Big problems -> lots of pieces! Difficult to understand & track n n n relation of pieces to each other & between pieces of design & code Pieces of design numbered 1, 2, 3… Number sub-pieces 1. 1, 1. 2… & 2. 1, 2. 2… Methods require naming pieces in design Include piece numbers in code too.
The TDSD Methodology n n n Understand the problem requirements Break into natural pieces, making sure to fully specify them and the order in which they are to be done Check whether these pieces done in this sequence solve the problem If no, revise & recheck until you have a set & order that do correctly solve it! If/when yes… repeat process with any non-trivial sub-pieces and so on until you only have trivial pieces! Finally, implement & test each of them separately, then integrate & test whole!
Tips… n Have you FULLY specified ALL the sub-pieces? and exactly how they fit together? n Sub-contracting Have you described the sub-problem in sufficient detail that someone would be able to solve it without any additional knowledge of the original problem? n Don’t be afraid to revise solutions or even scrap them entirely. It is not always possible to find best solution first time! n Don’t start to solve sub-problems until you are absolutely sure that the your proposed solution is correct. Doing so may waste time & effort. n n Must go from BIG to small -not small to big!! Your solutions must demonstrate you understand top-down design –require at least 2 or 3 levels n Robo limited to 20 line methods This must include comments! So ~10 comments + 10 commands (max, remember 7 +- 2)
Advantages of TDSD n n Small pieces easier to solve correctly! Projects easier to manage n n Projects can be completed quicker n n n easıer to reuse pieces can be done simultaneously Projects done in secrecy n n divides work naturally workers don’t see big picture Testing & integration is simplified
Summary n You should have learnt about & understand the rationale for… n n n n Comments White space Meaningfully named methods Method parameters Pre & post conditions Repetition Top down structured design! Happy programmin g. . . BYE
(a) base Library pieces! 100 x 100 3 2 1
- Slides: 21