210 likes | 221 Views
Learn software engineering through exercises involving house design and composite pieces. Understand the TDSD methodology, design, code relation, and advantages. Practice breaking down problems into manageable pieces.
E N D
Robo – Software Engineering …software engineering example exercise ... David Davenport Computer Eng. Dept., Bilkent UniversityAnkara - Turkey. email: david@bilkent.edu.tr
House Problem Who has attempted it?
250x250x250 2 roof 50x50 250 1 100x50 Pre-cond. Post-cond. main Robo – House Problem (1) • Specify pieces & order
1 7 3 5 main walls 2 4 6 main d walls d movetoleftwin d window d movetorightwin d window d movetodoor d door d movetoendpoint 150x25 Pre-cond. 150x75 150 window door Post-cond. movetoleftwin movetorightwin movetodoor Robo – House Problem (2) • Then solve pieces…
Software Engineering Exercise Form teams, implement, then reflect!
(2a + 2b) (a) (a) (b) base side topleft (a) (2b) toprightbottom (a) (a) (2a + b) moveup movedown topright (a) (a) 45 (2a + 2b) diamond Pre-cond. movetoleft Post-cond. Basic Pieces… (b) (a) lefttop
slice ( a, b, c) slicetop ( a, b) bc ( a, b) d base( b, c) d moveup( a) d slicetop( b, c) d movedown( a) d movetoleft( a, b)d topleft( b)d holder( 100, a, a)d topright( a, b) d side( b)x a slice( b, 12, 10)d side( b) holder ( a, b, c) d lefttop( a, b)d diamond( c)d toprightbottom( a, b) Composite Pieces…
Software Engineering Exercise The overall design!
tofirstcandle Birthday Cake Design 1 2 3 // birthdaycake d Rect(200,450) //cakebody d tofirstcandle d candles
tofirstcandle To First Candle // tofirstcandle p f(200) r(90) f(50) l(90) p
Candles // candles x 4 candle
1 2 3 4 Candle // candle d Rect(200,50) // candlebody d candlebodytoflame d Rect(40,40) // candleflame d flametonextcandle // candlebodytoflame 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 • Big problems -> lots of pieces! • Difficult to understand & track • 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 • 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… • Have you FULLY specified ALL the sub-pieces? and exactly how they fit together? • 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? • Don’t be afraid to revise solutions or even scrap them entirely. It is not always possible to find best solution first time! • 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. • 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 • Robo limited to 20 line methods This must include comments! So ~10 comments + 10 commands (max, remember 7 +- 2)
Advantages of TDSD • Small pieces easier to solve correctly! • Projects easier to manage • divides work naturally • Projects can be completed quicker • easıer to reuse pieces • pieces can be done simultaneously • Projects done in secrecy • workers don’t see big picture • Testing & integration is simplified
Summary • You should have learnt about& understand the rationale for… • Comments • White space • Meaningfully named methods • Method parameters • Pre & post conditions • Repetition • Top down structured design! Happy programming ...BYE
(a) 100x100 base Library pieces! 3 2 1