1 / 60

An “enjoyable” introduction to Programming

An “enjoyable” introduction to Programming. Dr. Jeyakesavan Veerasamy Senior Lecturer University of Texas at Dallas jeyv@utdallas.edu. Programmable device ?. What is programming?. Set up parameters such that same device can be made to do several different things. Why learn programming?.

edna
Télécharger la présentation

An “enjoyable” introduction to Programming

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. An “enjoyable” introduction to Programming Dr. Jeyakesavan Veerasamy Senior Lecturer University of Texas at Dallas jeyv@utdallas.edu

  2. Programmable device?

  3. What is programming? • Set up parameters such that same device can be made to do several different things.

  4. Why learn programming? • Automation continues… • Computer touches our lives more & more every day… • More component based programming  always room for simple programs to do large tasks!

  5. Learning to ride bicycle • Difficulties for beginners: • Difficulties for experienced folks:

  6. Solution • Training wheels • Helmet • Makes learning enjoyable and safe!

  7. Learning to program:Difficulties for beginners • Syntax errors • struggle for hours to fix syntax errors • Loose confidence • Frustrating experience • Run away & never come back if possible! 2. Logic errors Not a serious issue.

  8. Difficulties for experienced programmers Logic errors Continuous learning

  9. Solution • Visual Programming Tools to teach programming concepts without encountering syntax errors

  10. Introduction to Alice • Developed at Carnegie Mellon University and available freely for every one! • Website: www.alice.org • Alice 2.2 Software

  11. Programming Concepts

  12. A few examples • Recipe to make your favorite food • Assembly instructions for a toy • Coming to college from home What is common about these activities?

  13. Programming concepts:Sequence structure instruction 1; instruction 2; instruction 3; …

  14. A few more examples • Study at home or play cricket with friends? • Eat Parotta or Poori? • Go to Vijay’s movie or Karthik’s movie? • Go to job or go for higher studies? What is the common thing here?

  15. Selection structure IF condition is true THEN do this; ELSE do that; ENDIF

  16. A few more examples • Eat chips from a packet • Go on a shopping spree with lot of cash! • Take an exam that has several questions What is the common thing here?

  17. Repetition structure WHILE (more items to process) process the next item; ENDWHILE FOR month = 1 to 12 do monthly processing ENDFOR

  18. Object Oriented Programming (OOP) • Models the real-world better

  19. Purpose of Alice • Enjoyable introduction to Programming • Natural introduction to OOP • Learning to program with training wheels • Stepping stone to learn more serious languages (C/C++/Java)

  20. Hands-on Introduction to Alice It is a good idea to save each program separately so that you can go back and review later.

  21. Alice environment • World • Gallery • Creating the initial scene • Adding objects • Working with objects

  22. Program #1: Choose your favorite object from the gallery and make it an interesting setup. 10 minutes?

  23. Our first program! • Sequence structure • do a few interesting actions!

  24. Program #2: Make your object do a few funny actions! 10 minutes?

  25. Program #3 • Introduce multiple objects • do a few interesting actions!

  26. Program #3: Make your objects do a few funny actions! 15 minutes?

  27. Program #4 • Use DO TOGETHER structure • Add realism & sophistication!

  28. Program #4: Use DO TOGETHER to do multiple things at same time! 20 minutes?

  29. Program #4a • Add Vehicles/Seaplane from local gallery. • Make it do loop the loop. • Use DO TOGETHER structure • seaplane move forward • seaplane turn backward • seaplane’s propeller roll right • Use “style = abruptly” to make the motion smooth 

  30. Program #4a: Use DO TOGETHER to make the plane do loop the loop! 20 minutes?

  31. Program #5 • Introduce repetition – counted loop • do a few interesting actions!

  32. Program #5: Make your objects do a few funny actions multiple times! 10 minutes?

  33. Program #6 • Use condition to stop the loop. • do a few interesting actions!

  34. Program #6: Make your objects do a few funny actions multiple times, but stop when a particular condition is met. 15 minutes?

  35. Program #7 • How to do realistic walking? • Leg & body movements • Better to do with human objects • Create new methods

  36. Program #7: Practice human walking/running animation 15 minutes?

  37. Program #8 • Walking back and forth between 2 points? • Discuss the ideas before coding! • Use methods?

  38. Program #8: Practice human walking/running back & forth. 15 minutes?

  39. Program #9 • Alternate implementation of Program #8 using IF statement • Variables • Decision statement

  40. Program #9: Practice variables and decision structure 15 minutes?

  41. Logical thinking • You have been introduced to several building blocks – a few more on the way too. • Now, it is all about putting/using them together in various combinations. • I encourage you to think in high level, note down a few ideas (design), then proceed to implementation. • Direct coding is NOT recommended.

  42. Program #10: Lists/Arrays Arrays cannot expand during run-time, but lists can. Alice supports more functionality with lists too. In simple words, lists are more powerful. • Make a list of your favorite objects (multiple copies of an object is ok too!) • Make them do something one at a time. • Make them do something in random order • Make them do something in sync. • You are not limited to these - use your imagination!

  43. Program #10: Play with lists & practice each one. 15 minutes?

  44. Event-driven programming • Deletion of individual methods or objects possible - just drag it to Trashcan! • We will cover event driven programming today. • Analogy: handling interruptions when you are watching a movie or studying hard for an exam. • Related note: Time management is very crucial in modern life.

  45. Program #11: Events • So far, we did all the work under “my first method”. • But when it comes to games or complex apps, user may press various buttons/items & we need to respond to each event.

  46. Program #11: We will start with a coach and a ball. Coach keeps doing some exercise. We will use key based events to move a ball to top of his head. Then, coach should stop exercising and do something funny. 15 minutes?

  47. Program #12: Frog’s jumping game! • Swimming pool – moving lilypads – make the frog to jump on lilypads carefully and reach other side to win! • Make the lilypads to move independently back and forth first. Then, work on the game. • If the frog jumps and touches the water, it will sink! I guess this frog does not know to swim  • Plan and write the pseudocode first, before coding!

  48. Program #12: Frog jumping game. Discuss/share ideas with your neighbour and help each other to progress … Move frog 0.7 meters forward when up-arrow is pressed. For moving lilypads, use distance (pool width – cricle width) with bit random speed. Use vehicle property to stick to lilypad.

  49. High level idea/pseudocode #1 move the frog by 0.7 meters. IF index is beyond lilypads declare win! ELSE IF frog is close to circles[index] frog is safe set vehicle for frog to corresponding circle ELSE frog dies! – make frog disappear display a message ENDIF ENDIF increment index

  50. High level idea/pseudocode #2 move the frog by 0.7 meters. IF frog is close to “finish” object, declare win! ELSE IF frog is close to any of the moving circles frog is safe set vehicle for frog to corresponding circle ELSE frog dies! – make frog disappear display a message ENDIF ENDIF

More Related