LESSON 7

GOAL: Students will be able to…

  1. Explain the preconditions and postconditions of a function
  2. Create clear and readable comments in their code that help the reader understand the code
  3. Explain the purpose of comments
VOCAB: 
  1. Programming Style–The way your code is written is the style. It covers the aspects of the code that goes beyond whether or not it just works.
  2. Comment–A message in your code that explains what is going on.
  3. Precondition–Assumptions we make about what must be true before the function is called.
  4. PostconditionWhat should be true after the function is called

DO THE FOLLOWING IN ORDER:

  1. REVIEW:
    1. Do:  1.6.2 Top Down Design and Decomposition Quiz
    2. Do the Planning Programs 1 activity–get it from your teacher–work with a partner
  2. Click on example  1.7.3 Hurdle Karel. Read the code in green. What purpose do you think the code serves in the program? Does the code in green affect the program?
    1. Can you identify the direction and avenue that Karel faces in the starting world? This is known is as a precondition.
    2. Can you identify the direction and avenue that Karel faces in the result world? Also note the amount of balls in the tower and how many were built. This is known is as a postcondition.
    3. Complete The Two Towers + Comments exercise in pairs or individually.
    4. Because of your hard work with defining and calling functions, you have unlocked the super powers of Karel. These super powers are the ability to turn right and turn around without having to define it as a separate function.
    5. Examine the example in Hurdle Karel (with SuperKarel).
      *Students complete The Two Towers + Super Karel using the turnRight() command.
  3. If time permits: Go back through previous Karel exercises and add pre and postconditions to your code
  4. FYI: CodeHS Online Textbook–use this as a resource
  5. BEFORE YOU LEAVE, WRITE ABOUT THE FOLLOWING in the Word Online file named Web Apps & Coding for this class (you will write in this file daily):
    1. What are the two types of comments?
    2. What is the benefit of using comments?
    3. Are there times you wouldn’t write a comment? Why?

Leave a comment

Your email address will not be published. Required fields are marked *