Computer Science Teacher
Computer Science Teacher - Thoughts and Information from Alfred Thompson

March, 2011

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Object Oriented Programming is Dead



    OK perhaps not dead but Robert Harper, a professor at Carnegie Mellon University, says(Teaching FP to freshmen) that object oriented programming and design is “unsuitable for a modern CS curriculum.” More of the quote in context is:

    "Object-oriented programming is eliminated entirely from the introductory curriculum, because it is both anti-modular and anti-parallel by its very nature, and hence unsuitable for a modern CS curriculum."

    As you might imagine there is some dissent in the comments. When I posted this link to my Facebook page there were some 16 comments, mostly in disagreement, in a short period of time. One person, who hires people for industry responded with “I'm tired of interviewing interns who know Haskell but can't code up strlen() in C. ” But as Robert Harper says in a reply to a comment on his post “Our goal at Carnegie is provide students with an education, not training.” What does that mean anyway? Is there a conflict between industry and academia? Academics often believe that “There are plenty of opportunities for them to learn the old ways, and to pick up industry practices on the fly” while industry hiring managers lament the fact, as one VP told me, that it takes an average of a year and a half to turn a recent college hire from a good school into a fully productive software developer. Is is any wonder that many companies prefer not to hire people right out of college?

    I’ve seen programming paradigms come and go. I started programming as industry (and academia) were adopting structured programming. That was a big advance at the time but required some changes in the way people thought and designed code. Later I lived through the long, slow and at times even more painful transition to objected oriented programming. Are we entering the age of functional programming? Perhaps. But perhaps not to the exclusion of other paradigms.

    We do have new needs today. While first structured and later OOP developed to support the needs of larger programs and larger teams of developers as well as the needs of dealing with more data today the key new issue is parallelism. One of the design goals behind the development of F# (a functional language that is built into Visual Studio) is parallelism and making it easier to spread work across multiple processors. Clearly that is where we have to go to continue to be able to take advantage of the newest hardware. But does that mean OOP can become optional or that we can wait for students to learn it after college? That I am not so ready to buy.

    Even at the peak of OOP mania I have maintained that not everything has to be an object and that a mix of paradigms would/did/does work. I think that is still going to be the case even as functional programming grows in usage and popularity. But will old style programming completely go away? I don’t think so.Will objects go away? Not a chance.  I think universities, especially those who provide an “education not training” do their students a disservice if they ignore the reality of what is currently in the field. The handwriting is on the wall and functional programming is going to continue to grow in importance. But ignoring OOP now is not doing anyone any favors. Just my 2 cents.

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Programming Projects Using Arrays


    Not long ago someone posted a query to the AP CS list serve looking for projects that use arrays for them to use in their Visual basic programming course. The response was impressive. I decided to collect them all (with attribution to to people who sent them to the list) because I think it is a useful resource. These projects can pretty much be used with any programming language and range from very easy to a little more advanced. So if you are looking for some additional projects here’s a list. (BTW I played with the formatting a little to make it work on the web and fixed a typo or two but otherwise cut/pasted. All errors should be blamed on me though.)

    I do the project Alfred suggested below after I do a simple Cypher project. I never liked the fact that character arrays are not in the AP curriculum and I've always taught them. So, given an array of characters, you can encrypt that array in one of two ways (or you could use StringBuilder setCharAt method):

    1. 1. Add or subtract k to the characters that are letters (use Character.isLetter) and loop around so that nothing falls off the alphabet.
    2. 2. Create an array of characters of size 26 that defines which letters get replaced with which ones. For instance, if char[] code = {'c', 'q', t', ..., 'a'} then 'a' gets changed to c, 'b' gets changed to q, ..., 'z' gets changed to 'a'.

    A nice aspect of this method is the challenge of decrypting. Once we encrypt some text files, the question of how to crack a code is natural and the assignment below is excellent.

    L. LaSpina, Math & Computer Science, Bethpage High School

    The project I suggested and Leon referred to is one I have used for years. If fact I am pretty sure I wrote a project like this as an undergraduate so I don’t claim it is original with me by any means:

    I like to use arrays to count the occurrences of individual letters in text input. An array of 26 integers will do for case insensitive counting (in English anyway). After counting the letters they can display things like the most common letters, letters that do not appear, counts for each letter, etc.

    Games suggest a lot of ideas like these:

    I provide kids with a word list (Scrabble) and ask them more questions than they can answer about the English language. (How many words, longest words, list of palindromes, etc.) I can send the lab if you want.

    Also, I wrote some graphics classes to model the Lights Out Game and I have the kids write the Board class, which is a 2-D array. They like this because they can play the game when they are done. Again, I am happy to send it if you contact me.

    Jake Tawney, Columbus, Ohio

    This game from Matthew Harbinger is also based on a game. I have used it myself in Visual basic courses. Kids have fun testing it:

    Because you said VB, I'll share my VB array project. Students place 20 pictureboxes on the form and declare an array to hold 20 images. They shuffle the array, and a separate picturebox on the screen shows the first image in the array. They have to find its match on the form. When they click its match, the separate picturebox then shows the next image in the array... They must have a time limit and it resembles the kids game Perfection. They enjoy coming up with a theme and having a game we can play on the Smartboard.

    Loops and arrays go together like hand in glove as you can see from these two examples.

    Well, I happen to be smack dab in the middle of arrays in my Intro (Java) class right now. A couple things I've done:

    • Linear Search & Adding two arrays (both integer and String)
    • And for the next few days I'm showing them nested loops and thus, 2-D arrays, which they will search, and use nested loops to create things like:

    Gary Gongwer, Moreau Catholic High School, Hayward CA

    A couple of more involved examples from Christian Day including some talk of Big O notation and search efficiencies.

    You could start setting them up for binary search and more efficient data structures by having them perform something relatively complex (e.g. which word/number appears most frequently in this array of words/numbers? - a O(n^2) algorithm with array) and display a count of the number of times each individual array item is looked at.

    Other ideas:

    • Find the last index of a value in the array
    • Store a coded message in an array by storing the letters/words/numbers you are interested in in some series (e.g. the Fibonacci series, primes only, etc.), then write methods to extract the data.

    Of course, if they've hit all of the topics you mention, they may be ready for insertion and deletion. Good luck. Have fun

    Dice and randomness often adds to the fun as in these ideas from my good friend Debbie Carter. The addition of graphing is a great interest builder and allows for some more complex projects later on in a course.

    Use the elements of an array to tally a series of events. (element number = numeric result of event)

    For example, when rolling two dice, increment the element whose number is the sum of the values on the dice (so your tallies will be stored in elements numbered 2 through 12). Students can then display the results in a bar graph (or histogram).

    Debbie Carter, Secretary, CSTA - Northern NJ Chapter, Teacher of Computer Science & Mathematics Mt. Olive High School Flanders, NJ

    Brian Spotts also suggested a dice related project that honestly I think could use more detail but maybe it makes sense to you.

    Have them roll a die a number of times and count them.

    for (x = number of rolls)


    The “random walk” is actually a very common and useful concept for computer science students to learn. Here is one such idea:

    I have an exercise where students set up a simple int array and then simulate a "random" walk using a coin flip. The initial position is the middle of the array and if the coin flip is heads (0) move 1 step to the right, tails (1) move one cell to the left. Each time they move into a cell the cell is incremented. After flipping the coin a given number of times they then need to print out the total number of times the cell was occupied. I often make them print out "*" for each visit so that they can see the random walk graphically. I use this exercise to get at a number of topics: random numbers, how a random process can deviate from the expected normal distribution, moving from cell to cell in an array, incrementing values in an array, how to deal with moving out of bounds of the array, initializing and manipulating arrays, using the values in an array to control what is printed. It's fairly easy to set up and run and the results are always though provoking.

    George Murkowski, Upper School Technology Facilitator, The Wheeler School

    Mathematical challenges are often good as are exercises that requires any kind of searching for thing;

    Another project might be something along the lines of "Given an array of integers (maybe using Math.random()), find the greatest common factor (GCF), calculate the median, or average, or something along those lines.

    For something a bit more challenging, you could implement a simple "lookup code" array, where a sample string can be encoded by the use of a secondary String array as a lookup table.

    Sample: Encode the String "hello" by using the nth letter "above" each letter as an encryption scheme...e.g. five letters above "h" is "m". Repeat this for all letters in the array to encode the String.

    Michael Lew, Loyola High School, Los Angeles, CA 90006

    Leigh Ann Sudol-DeLyser, Carnegie Mellon University, posted some of her favorite ideas on her blog - Additional Activities with Arrays She goes into some helpful detail so rather than cut/past from her blog I recommend you go read them there. And follow her blog – she has lots of great ideas.

    Lockers! Now there is a subject most high school students can relate to. I like that this project as a sort of puzzle aspect to it as well.

    Locker Problem (arrays) – Write a program to simulate the following experiment. You have 100closed lockers. Start with the first locker and for every locker open it. Now, starting with the second locker, for this locker and every second locker after that, if the locker is open, close it; if it is closed, open it. Then, starting with the third locker, for this locker and every third locker after that, if the locker is open, close it; if it is closed, open it. Continue with the nth locker changing the “position” of every nth locker until n = 100. Print out the locker numbers that remain open. What do you notice about the lockers that remain open? Can you explain your results?

    Evelyn Torres-Rangel

    Duck, Duck, Goose is a cute little kids game but I think high school kids secretly miss it. This project lets them “play” with the game on the computer a bit.

    I have my students do a version of "Duck Duck Goose". I don't remember where I got it from. The user enters the number of players (>= 1) (I have them do an input-check loop here to be sure the number is >=0). A Boolean array is set up with all elements being initialized to true. Every third player is eliminated, only counting players that are still true. They need to keep track of the number of "trues" until it gets to 3, and change that player to false. Also need to skip over falses. Also need to deal with reaching the end of the array and going back to the beginning. (FYI - start tracking variable at -1) Eliminate players one less time than the size of the array - the element that is still true is the winner, but don't forget to add one to the subscript! (Ideas for extensions: redo with ArrayLists - can eliminate element all together, and I also have my Data Structures class redo the lab with a hard-coded circular linked list. Our student files are not cleaned out year to year so they can go back to the original.)

    After I wrote the program, I put it in a loop 1 - 100 players and printed a chart of number of players and the winner # so they (and I) have test data. Before assigning this lab, I have several students come to the front of the class and use post-its to put numbers on them and run a simulation, turning a student away from the class when they are false.

    Bonnie Sturm, Parsippany Hills HS, Parsippany, NJ

    I wrote a grading program for my project books and here Adam Michlin gives a quick version of one.

    I like to have students create a grading program. First project is storing and retrieving one grade for students (1D array... studentGrades[studentNumber]). After that, I expand to 2D arrays and have them store and retrieve grades for multiple assignments/grades (studentGrade[studentNumber][assignmentNumber]).

    -Adam Michlin

    Baker Franke suggested a project that was recently presented on the Nifty Assignments talk at SIGCSE called Evil Hangman. You can read the official explanation at the Nifty Assignments archive. Baker’s explanation is:

    The computer suggests a word for a simple game of hangman, and the player guesses letters and is only allowed a certain number of incorrect guesses...

    BUT...the computer is EVIL. The program just finds words of the given length that don't have any of the characters suggested by the

    player. The computer can almost always win.

    So, To START:

    The player suggests a word length and a number of guesses allowed

    Then the program should read a list of words of the given length from a file into an array (though other structures might be more appropriate in a big-oh sense).

    Each time the player suggests a letter, the program should remove any words from the list that have that letter in it.

    With enough guesses, the you'd eliminate all words, so make sure that at least one word is left in the list, and from that point forward it's just regular hangman.

    Well there is a start. Note that you can get my Visual Basic Project for the Classroom (PDF) and my Visual C# Projects for the Classroom books with a number of classroom tested projects. I also wrote an article on creating and using arrays of controls for both C# and Visual Basic that you can find on my web site – Creating and Using Control Arrays

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Interesting Links Post 21 March 2011


    My travel is over for a couple of weeks. Well, about three weeks. Then I will be headed out to Seattle for the US Finals of the Imagine Cup. Look for news of the public’s chance to vote for their favorites later this week. We, the US, have some great looking teams this year and I am hopeful they will do well in the world wide part of the competition. And now some links.

    Looks for some fun and educational contest sort of thing? Don’t miss a fun new software competition for younger students - Microsoft's Kodu Cup

    Kathleen Weaver has a nice post on One Note use  Planning and Presenting (Both for Teachers and Students) on her blog. She explains some of the ways she uses Microsoft OneNote

    The March Tech Student of the Month is Kenneth Harding (@kanno41)  from Ohio State University. He is one of those people whose parent started them coding and who have never stopped learning and growing. Take a look at all he has been up to.

    Go behind the scenes at Xbox with this talk with Larry Hyrb better known as @Majornelson

    Charlie Kindel ( @ckindel) from the Windows Phone team has a great Behind the Code interview. This is an interesting series of interviews with technical people at Microsoft who discuss their careers, the industry and their latest projects.

    My good friend Doug Peterson ( @dougpete) and I made a list of 300 educators on Twitter. If you are looking for educators to follow this is a nice place to start.

    Sam Stokes (@SocalSam) posted about how to use - XNA and Bing Map Geocoding

    Lyn Langit (@llangit) has been busy with resources for Small Basic lately. Last week she posted about some videos she has created at  Teaching Kids Programming–Video Training for Teachers

    College Students Aim to Build a Better Way to Manage Courses – What I love about this story is that students didn’t complain but rather said “we can do better: and then set out to prove it. This article highlights some resources available to software startups and so if you know a budding small business person point them this way.

    Cool! Windows Phone 7 app for NYC subways A must have for NYC subway riders. This is another story of a students seeing a need and developing software to solve the problem. I am thinking I may want to buy this app before my next visit to New York.

    Take a look at this video by Dan Kasun (@DanKasun) talking about making government information more valuable. Moving more government information to the cloud where more people can get at it in more ways is a great step towards making government more effective and responsive.

    lastly for this week, take a look at this Webcast Series for K-12 educators and teacher recognition program from Microsoft’s Partners in Learning program.


Page 3 of 10 (28 items) 12345»