EDS 221 Day 5 AM

Creating programs: planning


August 14th, 2026

Optimal stress


Yerkes-Dodson Curve

Exponential complexity


Course goals


Must

Grasp sufficient building blocks to continue your learning in the future.


You learned the alphabet and some basic vocabulary

Ideally

Develop intuition about how to use data structures, control structures, and functions.


You can write with correct grammar

Maybe

Fluently read and write code in R.


You can hold a conversation

Progress check


Written assessment

  • 4 sets of 3 questions
    • 1 set for each day this week
  • Questions increase in complexity
    • 1st question: building blocks
    • 2nd question: intuition
    • 3rd question: fluency

Problem decomposition



We’re going to re-run the coral reef model.

The model is a complex problem.

This time, as you’re running it, focus on finding simpler problems.

In the afternoon session, we’ll solve the simpler problems and put the whole thing together

Problem decomposition is how we apply our building blocks to solve complex problems.

Identifying components


What makes for a good component?

  • Not too big, not too small
  • Only one ultimate goal
  • (Relatively) self-contained

Good

  • “Roll 2d6”
  • “Initialize the reef”
  • “Grow a coral”

Needs revision

  • “Apply crisis rules” (too big)
  • “Set cell to 1” (too small)
  • “Loop through the years” (not self-contained)

Example of a component


Roll 2d6

  • Not too big, not too small. Replacing sum(sample(1:6, size = 2, replace = TRUE)) with roll2d6() improves clarity.
  • Only one ultimate goal. It calculates 1 number.
  • (Relatively) self-contained. No dependencies at all, simplest case.

Find a component


Your turn

  1. Find your group (see activity on course website)
  2. Run the model again
  3. As you run it, identify a component of the model
  4. Describe the component on your group’s slide
  5. Share with the class