(Latest Revision: 02/11/2002)
Week 01 Notes for CS 2500, Section 001 -- Spring 2002
CS 2500, Section 001, Thursday, February 14, 2002
First Day
- Take Roll.
- Announcement(s)
- Week 01 is short: class meets Thursday only.
- First Lab will be on Tuesday, Feb 19.
- Progamming I is a prerequisite for programming II, and
students without prerequisites may be dropped by the
instructor. See me after class if you have not passed
the equivalent of CS 1500.
- The first programming assignment is in place online.
- Pass around a sign-up sheet for new accounts.
- Discuss schedule for first week.
- Pass out course handout(s)
- Go over information in the course description.
- Show class where to get hello world handouts and Jove
handouts online:
- Assignment: Students should read the hello world
assignment. We will be doing the assignment together in lab
on Tuesday.
- Discuss top-down program design methodology using online examples of
level-one through level-three programs.
- First create a header comment for the program. Use the
specs in the assignment to create your description of
what the program does.
- Invent your algorithm: Conceive of a method for solving
the problem. The method must involve just a few steps.
Keep the number of steps small by not including much
detail at this level. A function must not take up more
than about 24 lines of code (a "screenful"). Less is
better.
- The algorithm must be complete: All required tasks
of the algorithm are covered by the steps given,
even though many details may not be explicitly
mentioned.
- The steps of the algorithm must be in the correct
order.
- Any loop, if-else, or other control structure must
be written correctly.
- Next translate the algorithm into C++, making it into
your main function.
- Make "steps" of the algorithm into function calls in
the main function. Include parameters in the calls.
- Create stubs for the function calls in the main program.
- Begin each stub by writing a header comment
telling what the function will do when
completed. (In other words, the header does not
tell what the stub function does. It tells
what the completed function will do.)
- Next write code for the stub function. Usually a
stub writes a message to let the user know when it
is executing. The stub must also return a value
if the caller expects one. If the caller expects
the function to set the values of other parameters
or variables, the stub must do that. Usually the
programmer just picks arbitrary values for the
stub to return or set.
- Compile and test the program. Fix any problems with
the main function and stubs.
- When everything checks out, start expanding stubs into
completed functions. How do you do that? Basically
you just do the steps above all over again. Now you
are working on a function at the next level down
instead of the main function. You must still defer
detail. Include only enough detail at each level so
that the function has just a few steps.
- You work like this over and over, going down
level-by-level. Eventually, there will be steps to
fill in that are so simple that they can be coded
directly into just one or two C++ statements. Once
you reach this "bottom level" everywhere in the
program, you are finished writing it.