Category Archives: programming activities

Fractal Tree Lab

I’m currently working on curriculum development for our AP Computer Science and our new textbook (Cay Horstmann’s [Java Concepts: Early Objects, 7th edition](http://www.horstmann.com/bigjava.html)). As part of this effort, my counterpart at our district’s other high school and I were sharing some of our favorite labs. One that I shared was the Fractal Tree Lab that my class did this year as part of the recursion unit.

I found this [fractal tree assignment](http://205.173.41.8/staff/peck_george/notemplate/JavaCS/FractalTree/FractalTreeGenerator.html) online when searching for a fractal example of recursion that my students would find interesting. I believe this assignment is authored by George Peck at Lynbrook High School, but I couldn’t find a reference to it other than through a Google search.

We started with example code for an applet that generated a [Koch Snowflake](http://en.wikipedia.org/wiki/Koch_snowflake). We then built upon this example to create our fractal trees. I’m fortunate that my inaugural AP Computer Science students were fantastic about providing me honest feedback throughout the year. For this lab, they shared that the assignment provided way too much support and I should have let them figure more of the algorithm out on their own. Based on this feedback, I edited the original assignment to provide less direction.

Download (PDF, 48KB)

The fractal tree should look like this:

Fractal tree

Along my goal of providing [differentiation and choice in programming activities](https://pedagoguepadawan.net/212/differentiation-and-choice-in-programming-activities/), I encouraged students to “add more awesomeness” to their fractal trees. Here are some examples of what they did:

Fractal Tree 1

Fractal Tree 2

Fractal Tree 4

Another student made an interactive fractal tree where you could adjust the growth of the tree with a scroll bar. Another made his fractal tree animated and grow slowly.

I’m looking forward to seeing what next year’s students come up with when provided less explicit support but some cool examples from this year’s class.

Differentiation and Choice in Programming Activities

I just finished teaching my first semester of AP Computer Science. I had no concerns with the content (I have a BS and MS in Computer Engineering, worked as a software engineer for a decade, and can recite Stroustrup’s *Design and Evolution of C++*). But, as I shared with students on the first day of class, I have experience teaching college graduates advanced software engineering techniques, not high school students how to understand programming. What I was lacking (and continue to lack) is pedagogical content knowledge (PCK). I hope to make it to an AP conference next summer or another workshop, but many of them seem to target the very important audience of “I just found out I’m teaching AP Computer Science and I’ve never programmed before.” What I’m looking for is a [Modeling Instruction](http://http://modelinginstruction.org/) workshop for Computer Science. If you have any suggestions for workshops that focus specifically on PCK, please [let me know](http://twitter.com/gcschmit). Despite my lack of PCK, I did stumble upon a couple of effective techniques that I wanted to share.

**Differentiation**

I have a very diverse collection of students in my AP Computer Science classes. I have students struggling in algebra 2 sitting next to students who are taking multi-variable calculus. I have students who debug race conditions on our FIRST Robotics programming team and students who are still struggling to distinguish types from variables. I welcome this diversity. I don’t think there should be a math prerequisite. Managing this diversity wasn’t nearly as challenging as I expected. In fact, I find it easier to differentiate in my computer science classes than I do in my physics classes. I do this is a couple of ways.

First, we spend most of our time in class programming. If a student isn’t working on their own program, they are most likely helping someone else with their program. Most of the programming activities that we do are learning activities and, therefore, not graded. I welcome and encourage their collaborative efforts. That’s how software is created in the real world. As a result, the students who need a lot of extra assistance get significant one-on-one time with me and students who need a little assistance get help from other students. This works quite well.

Second, I (and sometimes the students) create challenges for each programming lab. There is a certain base level of functionality everyone will achieve, but that will take some students two days and others twenty minutes. While the students that finish in twenty minutes can help others, I want to provide them a challenge that makes them stretch. I’ll illustrate with a couple of examples.

One activity was to write a palindrome tester. The challenge was to only examine letters and ignore punctuation. Students who met the challenge found some really long palindromes to test.

Another assignment was to use arrays to implement a stack of integers and then use that stack to implement a base-ten integer to binary converter. I defined a couple of challenges: implement a peek method and optimize memory usage by shrinking the array when it is way too big. However, the most popular challenge was found by a couple of students; they extended the program to support converting decimals from base-ten to base-two!

**Choice**

When practicing looping structures, I provided three different programming activities. One was mathematical: the program calculated multiples of a specified number and the challenge was to write another program that calculated square roots using Newton’s method. The second was printing based: the program printed a triangle of asterisks and the challenge was to print a diamond instead. The third was graphical: the program printed various sized boxes and the challenge was to make the graphics look like a Mondrian painting.

While providing students these challenges is good and helps keep all of the students challenged and engaged, the choice of how to apply looping structures in different contexts seems even more powerful and important. I’ve been reading a bit about the disproportionate representation of women and minority groups in computer science classes and these types of choices seem to align with some of the suggestions of how to interest everyone in computer science.

I spent the past couple of days skimming [Guzdial and Ericson’s *Introduction to Computing & Programming: A Multimedia Approach*](http://coweb.cc.gatech.edu/mediaComp-teach). Their approach is fantastic; I’m going to start next semester by applying our new knowledge of arrays to image and sound processing.

Looking forward to next year, I plan to interweave various application strands (multimedia, computational modeling, numerical methods, graphics, databases) as we learn the various concepts. I hope to expose students a bit to all these strands while permitting them to spend additional time and effort on those that appeal most to them. I may field test some of these ideas next semester with capstone projects if time permits.

The Game of Life and GridWorld

I love [GridWorld](http://apcentral.collegeboard.com/apc/public/courses/teachers_corner/151155.html), the case study for AP Computer Science. I think it makes the course much more authentic in that students experience developing software in a large (compared to what they are accustomed to) and unfamiliar code base.

One of the first labs that we did was the ActorBox lab published as part of the [A+ Computer Science](http://www.apluscompsci.com) curriculum materials. The students knew almost nothing about GridWorld and nothing about object-oriented programming, but they managed to figure out how to add Actors the the World. I introduced this lab as their first day on the job: “welcome to your new software job, here’s a large code base that you didn’t write and you don’t yet understand, figure out how to …”

Since then we have been learning the basics of Java, and now that we understand conditionals and loops, we can finally write interesting software. For the summative lab, I wanted to revisit GridWorld, emphasize the various phases of software development, and have them write a program that would be memorable. Implementing [Conway’s Game of Life](http://en.wikipedia.org/wiki/Conway’s_Game_of_Life) in GridWorld seemed to be the perfect fit.

I introduced Conway’s Game of Life last week and presented them with some initial requirements. However, I left a lot of the requirements unspecified. Students enumerated their own requirements on Friday and discussed them with me. I wanted them to realize that they needed to specify such requirements as the grid size, how to represent alive and dead cells, when the program finishes, and the time between generations. Students came up with a variety of ways of specifying these requirements with various levels of user specification. Students then started working on their design (flow charts or pseudocode; we haven’t touched on UML yet). This weekend, the were to enumerate their test cases and they will start implementation this week.

Through all of this, I continuously stressed that their requirements and design should be treated as living artifacts and will evolve as they progress through this lab. (I’m a huge proponent of Agile Software Development Methodologies, but that is a subject for another post.)

Since, at this point in the semester, my students are not that familiar with object oriented design, their solutions will be a functional approach and, most likely, inefficient and implemented with brute force. They will get to apply their newly acquired conditional and loop structures. I also think they will better appreciate the upcoming units related to object-oriented design as a result of this experience. In fact, I’m planning on a future lab to be going back and refactoring their Game of Life program.

Here’s the assignment that I posted:

Download (PDF, 46KB)

I think this may be my first computer science, related post… cool.