robo lectures

Information about robo lectures

Published on November 14, 2007

Author: Mee12

Source: authorstream.com

Content

Robo :  Robo David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey. email: [email protected] ...a lightning introduction to the engineering of software IMPORTANT…:  IMPORTANT… Students… This presentation is designed to be used in class as part of a guided discovery sequence. It is not self-explanatory! Please use it only for revision purposes after having taken the class. Simply flicking through the slides will teach you nothing. You must be actively thinking, doing and questioning to learn! Instructors… You are free to use this presentation in your classes and to make any modifications to it that you wish. All I ask is an email saying where and when it is/was used. I would also appreciate any suggestions you may have for improving it. thank you, David. Robo:  Robo Robo is a little robot with a pen you command him to move around he leaves a trail with the pen as he moves Robo’s world is infinite flat white surface Your objective: to have Robo produce given pattern/picture Robo:  Robo Commands f(x) - move forward x units r(x) - turn right x degrees l(x) - turn left x degrees p - pick up/put down the pen (switch drawing mode on/off) Initial condition middle of surface facing north in drawing mode One command at a time please! (i.e. only one per line) Sorry, but I can’t do any maths or even fractions! Robo - examples:  Robo - examples Have Robo draw a straight line 100 units long a horizontal line 150 units long a 100 by 200 unit rectangle an equilateral triangle with 150 units sides a dashed line, 50 unit spaces, 100 unit dashes Points to note: Robo only understands f,r,l & p (not any natural language) Syntax error when Robo doesn’t understand command A program is a sequence of commands (instructions) Multiple correct solutions Simple isn’t it? Robo - problem:  Robo - problem What is this? No one can IMMEDIATELY say what it is! How can we find out? TRACE it put yourself in position of Robo and follow the commands Robo - solution:  Robo - solution After tracing... program has Logical Errors & needs to be corrected... DEBUG the program BUGS Robo - TRACE & DEBUG:  Robo - TRACE & DEBUG Debug it... & check by tracing again! To correct... add, remove & change commands Homework!:  Homework! Try one of these yourself Star Computer House Robot Tree Cube Important your program should be correct i.e. it should be right-first-time Robo is asked to do (run/execute) it Motto: Design not experiment. Reflections:  Reflections Your observations…? There must be an easier way to earn a living! How can we make our lives as programmers easier? Simple to follow Difficult to understand Long & therefore complex to do Difficult to debug and/or change Often use same/similar sets of commands Ok, now Robo programmers earn living by writing them but only if right-first-time! & jobs require HUGE pictures The easy life...:  The easy life... Ideas to make life easier comments blank space methods parameters repetition Top down structured design Root cause of difficulties:  Root cause of difficulties Lack of mapping btw problem & solution l(90) f(50) l(90) f(100) l(90) f(100) l(90) f(100) l(90) f(50) r(90) f(150) l(90) f(70) r(120) f(140) r(120) f(140) r(120) f(70) see some structure see no structure So add notes Problem: notes would cause syntax errors! Solution: modify Robo to ignore such notes. Comments:  Comments Are natural language notes written in the program Ignored by Robo (i.e. no syntax error) // any_natural_language_text syntax: // Wishing Well // Author: David // Date: Sept. 2002 // draw base l(90) f(50) l(90) f(100) l(90) f(100) l(90) f(100) l(90) f(50) r(90) // draw pole f(150) l(90) // draw roof f(70) r(120) f(140) r(120) f(140) r(120) f(70) Use comments… to say what each section does, & to tell about the program as a whole Every program should have a Header, a block of comments at the top that detail what, where, when & by whom. Comments:  Comments Are natural language notes in program Ignored by Robo (i.e. no syntax error) Use for documentation purposes who, what, when, how, … // any_natural_language_text syntax: // Draw a house // Author: David // Date: Sept. 2002 : // draw walls : example: : : // draw left window : // draw door : Including information that explains how program works makes it easier to fix/change Tip: if changes are made, add comments to track who did what, when & why! Aids to Reading:  The Inheritance of the Labour Movement The British Labour Movement draws its inspiration from a history that goes back over many centuries. This movement arose directly from the twin struggles by the British people to control Parliament through the popular vote and to gain the right to organise free trade unions. The battle against the Combination Acts and similar legislation which made trade unionism illegal went hand in hand with the campaigns for working men and women to be represented in Parliament. But even before these historic struggles, which first saw the light of day in the industrial revolution, the origins of socialism can be traced back as far as the time of Christ himself and even to the Old Testament. Tony Benn, 1979. Aids to Reading Can you read this comfortably? theinheritanceofthelabourmovementthebritishlabourmovementdrawsitsinspirationfromahistorythatgoesbackovermanycenturiesthismovementarosedirectlyfromthetwinstrugglesbythebritishpeopletocontrolparliamentthroughthepopularvoteandtogaintherighttoorganisefreetradeunionsthebattleagainstthecombinationactsandsimilarlegislationwhichmadetradeunionismillegalwenthandinhandwiththecampaignsforworkingmenandwomentoberepresentedinparliamentbutevenbeforethesehistoricstruggleswhichfirstsawthelightofdayintheindustrialrevolutiontheoriginsofsocialismcanbetracedbackasfarasthetimeofchristhimselfandeventotheoldtestamenttonybenn1979 Blank Space:  Blank Space Help visualisation & reading Blank lines, indentation & spaces // Wishing Well // Author: David // Date: Sept. 2002 // draw base l(90) f(50) l(90) f(100) l(90) f(100) l(90) f(100) l(90) f(50) r(90) // draw pole f(150) l(90) // draw roof f(70) r(120) f(140) r(120) f(140) r(120) f(70) First see 3 parts then comments then code Combine Comments & Blank space Answers without tracing! Aid debugging & maintenance What does this code do? // Wishing Well // Author: David // Date: Sept. 2002 // draw base l(90) f(50) l(90) // left f(100) l(90) // bottom f(100) l(90) // right f(100) l(90) f(50) r(90) // draw pole f(150) l(90) // draw roof f( 70) r( 120) f( 140) r( 120) f( 140) r( 120) f( 70) Extend Robo to avoid syntax errors! Methods:  Methods Are named blocks of commands Short, so easier to understand Facilitates reuse, testing & debugging Wishing Well using methods:  Wishing Well using methods & again…?:  & again…? Changed method names What does it do now? (remember comments are ignored) …it looks like a wishing well, but… MORAL – use meaningful names! Some demo programs…:  Some demo programs… What is this… It should look like this… Can you debug it? What is this? Can you add a door knob or curtains? Note: These demos are located in a separate subdirectory and need java to run! Switch to an MSDOS window, change to the demos directory, (cross fingers) and run manually by typingjava TryRobo filename Generalise methods:  Generalise methods Looking at specific method instances notice repetition of similar code so, abstract/generalise through parameters Can you write equtri? Using general methods:  Using general methods Example, in place of draw door: d door Need to say “draw rectangle with width=50 & height=150” Use notation d rect( 50, 150) Actual parameter values Rewriting the house program:  Rewriting the house program Using general rectangle method in place of draw door: d door say “draw rectangle with width=50 & height=150” i.e. d rect( 50, 150) in place of draw walls: d walls say “draw rectangle with height=250 & width=250” i.e. d rect( 250, 250) Now need comments! Restricted parameter names!:  Restricted parameter names! Robo allows only names: a, b, c, d translate rect method for Robo… Robo methods always have these four formal parameters, even if they are not used. For this reason, they are not explicitly written each time. Now need to include comments to say what a, b, c & d represent… // Params: a – width, b - height Methods are independent!:  Methods are independent! Methods can call other methods only connection is parameter list matched one-by-one in order, not by name! Must understand: a’s, b’s, etc. are differentin each method. Repetition:  Repetition Automatically repeat method x number_of_times method_name ( parameter_list ) syntax: Try doing square & rewriting equtri Summary:  Summary You should have learnt about & understand the rationale for… Comments White space Meaningfully named methods Method parameters Repetition Coming next… Top-down structured design!

Related presentations


Other presentations created by Mee12

08 Dog and Cat Nutrition
16. 11. 2007
0 views

08 Dog and Cat Nutrition

miguel angel bustamante
01. 10. 2007
0 views

miguel angel bustamante

Athens 2004
02. 10. 2007
0 views

Athens 2004

hauer1
27. 09. 2007
0 views

hauer1

aws
06. 11. 2007
0 views

aws

Chapters 9 10
26. 11. 2007
0 views

Chapters 9 10

ContinuousIntegration final
28. 11. 2007
0 views

ContinuousIntegration final

N A V I G T O R S VBB 2007
30. 11. 2007
0 views

N A V I G T O R S VBB 2007

Fruit Insects
01. 12. 2007
0 views

Fruit Insects

raghavachari
04. 12. 2007
0 views

raghavachari

Test Anxiety 1
06. 12. 2007
0 views

Test Anxiety 1

ProvidentialHistory
31. 10. 2007
0 views

ProvidentialHistory

chap08 og
01. 11. 2007
0 views

chap08 og

handout 184637
05. 11. 2007
0 views

handout 184637

2004 harm present
05. 11. 2007
0 views

2004 harm present

E DESC AK PACOM POL CONF ver31
13. 11. 2007
0 views

E DESC AK PACOM POL CONF ver31

bedeutung innovation
15. 11. 2007
0 views

bedeutung innovation

Parity01 grames slides
23. 11. 2007
0 views

Parity01 grames slides

GA Conf07Lomas
13. 12. 2007
0 views

GA Conf07Lomas

CooperativeLearning
17. 12. 2007
0 views

CooperativeLearning

Friendship 1
23. 12. 2007
0 views

Friendship 1

plant lifecycles
28. 12. 2007
0 views

plant lifecycles

Millay
28. 12. 2007
0 views

Millay

alterman pki 05 13 01
01. 01. 2008
0 views

alterman pki 05 13 01

RMA 2005
02. 01. 2008
0 views

RMA 2005

OH
04. 01. 2008
0 views

OH

pp Bioeconomy Polansky Dec2007
04. 01. 2008
0 views

pp Bioeconomy Polansky Dec2007

nazca lines
07. 01. 2008
0 views

nazca lines

4330IBS
30. 10. 2007
0 views

4330IBS

Wk4 Mon
04. 01. 2008
0 views

Wk4 Mon

lh1
21. 11. 2007
0 views

lh1

econ and mgnt of privatization
20. 11. 2007
0 views

econ and mgnt of privatization

jre imps2005
06. 11. 2007
0 views

jre imps2005

EE541 451 class29
28. 11. 2007
0 views

EE541 451 class29

Aquatic Equipment
08. 11. 2007
0 views

Aquatic Equipment

WomensEmploymentJan2 001
24. 02. 2008
0 views

WomensEmploymentJan2 001

1025 QM05 Nardi
29. 10. 2007
0 views

1025 QM05 Nardi

wendybear
24. 12. 2007
0 views

wendybear

Martinac
14. 03. 2008
0 views

Martinac

DynaMed
25. 10. 2007
0 views

DynaMed

IntStu
27. 03. 2008
0 views

IntStu

Country Risk Sep07
13. 04. 2008
0 views

Country Risk Sep07

Eco 336 Constitutional Limits on
17. 12. 2007
0 views

Eco 336 Constitutional Limits on

2003 lecture crypto1
31. 12. 2007
0 views

2003 lecture crypto1

Ders1
29. 12. 2007
0 views

Ders1

REDLOBSTER
07. 12. 2007
0 views

REDLOBSTER

WarmUps WHII
25. 12. 2007
0 views

WarmUps WHII

pres riccardo
30. 10. 2007
0 views

pres riccardo

Chapt3overhead
12. 11. 2007
0 views

Chapt3overhead

SHFA280301
28. 11. 2007
0 views

SHFA280301

IfA jan03v1
15. 11. 2007
0 views

IfA jan03v1