Download presentation
Presentation is loading. Please wait.
1
Robo – Software Engineering
…software engineering example exercise ... David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey.
2
House Problem Who has attempted it?
3
Robo – House Problem (1) Specify pieces & order roof main Pre-cond.
Post-cond. main roof 2 1 250x250x250 50x50 100x50 250 Break problem into few natural pieces, specify sequence, specify sizes, specify pre & post-conditions. Ask: do these pieces done in this order produce the required solution? Yes, proceed. No, try again! Ask: Could you “subcontract” each piece? Is there sufficient information to produce that piece (without knowledge of any other piece or the problem), such that if done correctly (i.e. to your specifications) then it must (is guaranteed) to fit into your solution. Note: missing dimensions means that if the roof is sub-contracted it may be too big or too small to fit our house! Can use equtri for roof, so just need to think about main only.
4
Robo – House Problem (2) Then solve pieces… window door main walls
Pre-cond. Post-cond. walls window door 150x25 movetoleftwin 150 movetorightwin 150x75 movetodoor 7 1 3 2 4 6 5 main NOTE: This is not correct. It does not solve the given problem! WHY? Post condition is not met. FIX. Can reuse rect method for walls, door & windows. ? Can we generate a general move method to handle all these cases ? Notice… so far no Robo code, only design on paper. IMPORTANT: Design then implementation, not the reverse! When implementing… do each piece separately & test the unit (unit testing) before integrating. Hint: make special markstart & markend methods to indicate pre/post-conditions during testing/debugging. d walls d movetoleftwin d window d movetorightwin d movetodoor d door d movetoendpoint main
5
Software Engineering Exercise Form teams, implement, then reflect!
6
Basic Pieces… topright movetoleft base toprightbottom diamond topleft
Pre-cond. Post-cond. Basic Pieces… (2a + b) topright (2a + 2b) movetoleft (2a + 2b) base (a) toprightbottom (b) (2b) (a) diamond 45 (a) topleft Note: names are deliberately vague in order not to give the game away! (b) (a) moveup (a) movedown (a) side (a) lefttop
7
Composite Pieces… bc ( a, b) slice ( a, b, c) slicetop ( a, b)
d side( b) x a slice( b, 12, 10) d side( b) bc ( a, b) d base( b, c) d moveup( a) d slicetop( b, c) d movedown( a) slice ( a, b, c) Note: names are deliberately vague in order not to give the game away! d movetoleft( a, b) d topleft( b) d holder( 100, a, a) d topright( a, b) slicetop ( a, b) d lefttop( a, b) d diamond( c) d toprightbottom( a, b) holder ( a, b, c)
8
Software Engineering Exercise The overall design!
9
Birthday Cake Design Game’s up!
Of course, now we need sizes (in terms of parameters) plus pre & post conditions, etc. Maybe describe in english… beginnings of algorithms?
10
Birthday Cake Design 1 2 3 tofirstcandle // birthdaycake
d Rect(200,450) //cake body d tofirstcandle d candles
11
To First Candle tofirstcandle // tofirstcandle p f(200) r(90) f(50)
12
Candles // candles x 4 candle
13
Candle 1 2 3 4 // candle // candlebodytoflame // flametonextcandle
d Rect(200,50) // candle body d candlebodytoflame d Rect(40,40) // candle flame d flametonextcandle Candle 1 2 3 4 // candlebodytoflame p f(200) r(90) f(25) l(135) // flametonextcandle p r(135) f(25) r(90) f(200) l(90) f(50)
14
SUMMARY Advantages of TDSD The TDSD methodology
15
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.
16
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!
17
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 )
18
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
19
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
21
(a) 100x100 base Library pieces! 3 2 1
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.