Title: CS1321: Introduction to Programming
1CS1321Introduction to Programming
- Georgia Institute of Technology
- College of Computing
- Module 3
- Design Recipe Introduction
2Designing Programs
3Outline
- Prerequisites
- Basic Scheme Syntax
- Objectives
- Basic recipe for program design
- Purpose
- Examples
- Body
- Tests
- Reference
- HTDP Section 2.5 Designing Programs
4Road Map
- Foreign Language
- Grammar
- Vocabulary
- Phrases, Sentences
- Conversation
Computer Language Syntax Defined
Words Abstraction Problem Solving
Start conversing from the first day
Start solving problems from the first day
5Design Recipe
- Incredible way to guide your programming
experience - Well present examples of the Design Recipe in
this lecture and many others - For you HW, be sure to see the HW Skeleton linked
on the course website under the HW section. It
gives the format you are to use for homeworks.
6The basic design recipe Contract ltnamegt
ltvariable typegt -gt ltvariable typegt Purpose A
brief description of the problem Example
ltexample of what you would put ingt should
produce ltexample of what should
happengt Definition ltput your code
heregt Tests ltput your tests heregt
7Our revision... Name John Doe GT
Numbergt1234a Homework ltnumbergt (and more
see the HW Skeleton on the website under
Homework!) Collaboration Contract ltnamegt
ltvariable typegt -gt ltvariable typegt Purpose
A brief description of the problem Example
ltexample of what you would put ingt should
produce ltexample of what should
happengt Definition ltput your code
heregt Tests ltput your tests heregt
8Lets work through an example
Write a function area-circle that calculates
the area of a circle. It will consume a number
and return a number.
9Contract
Contract area-circle number -gt number
10Purpose
Purpose Calculate the area of a circle given
the radius
11Example
Example (area-circle 5) should produce
78.5
Alternatively
Example (area-circle 5) --gt 78.5
(area-circle 1) --gt 3.14
12Definition
Definition (define (area-circle radius)
( 3.14 ( radius radius))
13Tests
Tests (area-circle 5) expected 78.5 (area-c
ircle 10) expected 314
14Do I have to do this?
yes!
15Do I have to do this?
And it works!
16Summary
- You should now know
- Basic recipe for program designsee page 21 or
http//www.htdp.org/2001-01-18/Book/node14.htm - Purpose
- Examples
- Body
- Tests
- Recipes are required. See HW webpage and course
webpage for more requirements regarding recipes
and format for HW for this course.
17Assignments
- Read section I Processing Simple Forms of Data
- HW 1 is due tomorrow at noon..
- Keep reading newsgroup .announce every day.
- Lab 1 covering email and newsgroups is online,
due tomorrow at noon.
18(No Transcript)