Slashdot Mirror


Memorable Programming Assignments?

Albert Schueller asks: "This fall I'll teach introductory programming for the third time. The class is generally populated by students from a wide range of backgrounds and interests-liberal arts and science types. While we use C++, the language isn't really the issue. Rather, the goal is to introduce basic programming ideas like loops, logic, modular programming etc. What are some of your favorite programming assignments that would be appropriate for students at this level?"

8 of 127 comments (clear)

  1. Whatever you pick by Anonymous Coward · · Score: 1, Insightful

    step 1:
    Make it a game. They'll have fun, a few will even want to expand on it. Let them (preferably tell them beforehand they'll get better grades for well-programmed more elaborate versions of the game).

    step 2:
    let them choose which game, and give a basic explanation of an algorithm to drive the game (overlaying arrays for tetris, function-mapping for roads for a simple racing game, collision detection for asteriods (point them at at least 5 websites explaining this, as it gets rather mathematically), using unique pixel colors for platform games, ...)

    step 3:
    teach them to get network play operational (use kdegames for this, you won't regret it)

    step 4:
    give +2 for a kde game ;-). Watch them flow in. Community will be grateful ;-)

    just my .02 cents

  2. Re:You guys are all nuts!!! by eXtro · · Score: 2, Insightful

    I think your students just had a piss-poor teacher. In our first computer science course in high school we programmed a blackjack simulation once we had the basics down. Many of us were proto-geeks, but only one of the class had any actual prior experience. This was done on Commodore Pet's, the Vic 20 wasn't going to be around for another year or so.

  3. Ah, 15-127 by nadador · · Score: 4, Insightful

    (Oh, to be a freshman again. To take a "programming" class. To never have heard things like "this implementation is O of log n" or "NP complete" or "software cost estimation" or "preemptive fixed priority scheduling"...)

    The only assignment I remember from my first programming class was one in which we read in stuff from a file into a linked list, printed it forwards and then printed it backwards. The abstraction of the linked list was so cool, and when it actually worked I felt like king of the nerds (little did I know the horrors to come).

    When I was at CMU, there was one intro to programming class, and it was no fun for anyone. Now they've broken it up into people-who-might-take-another-CS-class, and people-who-don't-like-smelling-like-the-cluster, hence a class that is very light on fun and heavy on syntax and object oriented garbage, and one light on programming and heavy on pointy clicky fill in the blanks and make a game happiness.

    stepping onto my soapbox:

    While we're talking about intro classes, I think everyone who is going to take any additional classes in computer science, especially in the systems area, should take their first class in C, and it should be no fun. Every now and then you can toss them something fun, but learning the discipline of malloc/free, strncmp, etc., will serve you so well when you get to do object-y type computer science stuff. Writing good code, in a scientific or engineering sense, is just like learning to use UNIX - if you didn't suffer, you didn't learn. And if you get to new/delete or just new and then forget about it, you never learn the discipline that writing good code demands.

    -- steps off soapbox.

    --

    Outside of a dog, a book is a man's best friend. Inside a dog, its too dark to read.
  4. Re:The programming assignment I remember by pete-classic · · Score: 3, Insightful

    Most of the suggestions have been too hard and/or in the wrong language. This one is WAY too easy. AND it doesn't teach any 1st semester CS stuff. Well, okay, one loop.

    As for a general response, all the books that I used for CS (C++ 1,2,3 and intro is asm) Had both example projects and "problems" at the end of the chapter. Why don't you open the text you are teaching out of or *gasp* go down the hall to the library and check some books out.

    One I happen to remember is along the lines "Write a program that guesses a number between 1 and 1000 in as few guesses as possible. Detect lying by the player." This is a perfect first semester problem. It forces the use of screen and keyboard I/O, it forces the use of loops. By assignment you can demand that it is broken down into functions. It introduces the idea that you have to detect and deal with bullshit input.

    Finally, to all those to say "make it something fun" or "make it games" GROW UP. Go to a bullshit "tech institute" if you need the professor to spoon-feed you and forcibly retain your interest.

    -Peter

  5. GAMES!!! by windchill2001 · · Score: 2, Insightful

    As many othe rpeople have said, GAMES!!!

    For example start with somethign simple like Hangman, then move to somethign a little more difficult like the towers of hannoi (spelling?) I also had a lot of fun programming the game of monopoly in my introductory programming class. So many diffrent objects to create!

    --
    -Windchill2001 The One, The Only, The Cold...
  6. Re:immediate, fun feedback by bluGill · · Score: 3, Insightful

    then the staff (you) could write a nice gui

    I like this bit of evilness: write your GUI beforehand, and then write a specifican, but make it wrong. Tell the students that the GUI won't be ready for a week, but they will be graded on how they interact with the GUI. Tell the class to write the program and test code to prove the interface works (error checking not required). On the day the assignment is due, collect the their program and the test code, and give them the GUI in library format (previously announced that way of course). Make sure the library doens't impliment the specification, but just tell the students "I will be testing with this GUI, not your test program, since you didn't have time to test with my implimentaiton I'll accept revised versions that work for one week, you will lose points, but not as many as if your program doesn't work. Of course you know that their program will not work with the GUI so they don't lose points, they just sweat a little.

    Evil, but fun to do, and it fits the real world very closely.

  7. Make the output cool by ginsu · · Score: 2, Insightful
    My younger brother's been beating his way through AP computer science this year, so I've had a chance to think about this issue quite a bit.

    The best way to make people (moderate geeks at least) excited about the programs they write is when they are excited about the output they produce. There are a few ways to get those results:
    1. A very easy graphical library. Perhaps a simple physics-with-visualization library, or a stripped down 2d sprite manipulator. People would much rather write 'pong' if it's a GUI app than writing pong thats played in a little gimpy text window. If you make it as easy or easier to do the former than the latter, they'll be more excited with/proud of the results.
    2. Provide a program which filters their output. You wouldn't want people to have to deal with learning (let alone generating/outputting) something like HTML or flash files or DXF files or whatever you can think of. They have other classes for that. But if you can define a simple 'language' which, in turn, generates one of those more complicated file formats, they can again be proud of their output. For example, I wrote a small program for my brother which would parse his input files and spew out POV RAY files. A very limited set of scenes were possible (specifically, it was a logo generator -- you chose fonts, colors, textures, lighting etc) but his program was able to generate very simple '.logo' files to drive it. So his ~100 line C++ program had cool 3d rendered output. Beyond graphical things (which I've focused on so far) you could create tiny languages which, for example, created animations -- or midi files, or wavs, or ...


    In essence what you are trying to avoid is the "I'm embarrassed to be proud of this" factor. The first time you pick up a musical instrument and haltingly jam out "mary had a little lamb" it's a huge moment. But you can't stroll into class the next day and say "dude, check it out. Last night I was playing Mary Had a Little Lamb. Oh yeah, I'm serious." If you can avoid the analagous situation, make programming fun while teaching fundamental skills, then even for non-geeks the 'ugh I don't want to do -that-' inerta factor is easier to overcome, hence making teaching fundamentals (and grading, no doubt) easier and more fun as well.


    But what do I know . . . I took all my intro courses with hardcore CS majors. We were excited about spewing out ASCII UI's :)

  8. A good "beginner" programming assignment by da0g · · Score: 2, Insightful

    The best "beginner" programming assignment that I ever heard of was about sorting. Very fundamental stuff. But the items to sort were graphically displayed, with a simple API to swap two items. The goal was to let folks see their software in action.

    In an improved version of this approach, each student was told to sort the numbers, and given the initialize(), value(i), and swap(i,j) functions. But they were not told how to perform the sorting. Afterwards, each different sorting algorithm that was implemented was described by the students, and the professor covered any techniques that had been missed. This leads to a discussion of O(N^2) vs O(NlogN). And a future assignment to implement and compare (graph) the efficiencies (number of swaps) of different sorting algorithms.

    Ultimately, if you can foster a attitude of "here's a little bit, lets see how far you can take this", and then shape their results further, they will learn far more.

    The most instructive assignment I ever had was based on this. It involved writing a simple 3D perspective drawing program from scratch. The instructor said we could use any language, on any computer, and write the code any way we wanted to. Grades were entirely based on how well it ran. Some time after we turned it in, he announced the next assignment: Extend the previous assignment to handle shading from multiple light sources. That assignment, whether intentionally or not, taught me more about commenting and documenting my code than anything else ever did.