Program Logic and Design

May 23, 2024

Program Logic and Design

Structure of Code

Spaghetti Code

  • Unstructured, tangled program statements
  • Comparable to tangled spaghetti
  • Programs may work, but:
    • Difficult to read
    • Hard to maintain
    • Prone to errors
  • Often scrapped or abandoned due to complexity and cost of updates

Examples of Issues with Spaghetti Code

  • Example: Unstructured logic for washing a dog
    • Steps may seem logical to someone familiar with the process
    • Difficult to follow for someone unfamiliar with the process (e.g., not an animal person)
    • Flow lines should not cross
    • Hard to maintain and read
    • Logic is unclear (e.g., whether to shampoo or rinse the dog at any point)

Transition

  • Next discussion: Strategies to structure programs
  • Understand the three basic structures of programming