Archive for the ‘Teaching’ Category.

A Few Semaphore Based Programming Problems

I’m a big believer in practice when it comes to learning programming techniques. Although this seems obvious, it tends to go against the grain for most developer/teachers (like me) who love cool projects. What’s the best way to learn (say) scheduling? Write a scheduler! Our students did write a scheduler in OS, but they probably spend 90% of their time dealing with weird C mistakes and about 10% actually thinking about scheduling. More importantly, they only wrote 1 scheduling algorithm. If you really care, they have to write 10 scheduling algorithms. I didn’t care that much about them being able to code schedulers, but I did care about them being able to use semaphores. So I needed a bunch of tiny semaphore assignments. I’m sure I’m not the first teacher to do so, but I couldn’t find ones online when I looked.

So here’s a bunch of small problems that use semaphores. Some of these I used as 2 semaphore homework assignments, some of these I used as semaphore exam questions. If I were to try and arrange them easy-to-hard, it would be: threeAndTwo, abcd, hammerAndSaw, littleRedHen, balloon, printerQueue, producerConsumer, pair. Solutions are available too, if you email me.

Thanks to Ian Ludden who write littleRedHen and balloon for me. Also, a shout out to Allen B. Downey who’s awesome free book The Little Book of Semaphores is maybe the best treatment of the topic I’ve seen. I would love to go through that entire book in my class, but there’s not enough time in the current incarnation.

If you have any problems of your own, please send them my way! My students could use the practice!


(Contains 10 attachments.)

1-credit course in GIT

This spring I decided to try something I’ve been mulling over for a long time – a 1-credit course in GIT. 1-credit CSSE classes at Rose tend to be minor affairs…generally just for student fun and not affecting graduation. Of course, we already use git in many classes at Rose-Hulman, but you usually can’t cover anything in more detail than basic checking-in, checking-out, and conflict resolution.

10 classes was a bit on the longish side…I think you definitely could have done the topics in 7ish-classes if you wanted to compress, and the curriculum will always tighten with time. I do think that it’s wishful thinking to expect students to be good at git with just a lecture or two and some sort of highly structured tutorial.

The design of the course also was a challenge. Lecturing about command line tools is not usually effective – you have to use it to get good. I toyed with the idea of making a series of broken repo states that the students would have to fix/debug, but decided it would be too much work (if anybody would like to help me by make a library of 45 or so….feel free to get in contact with me, I still think that could be good). What I decided on was lectures, supplemented by a textbook (Git Pro), followed by weekly programming assignments were students had to write scripts that used git commands (and parsed the output). This was a course for moderately senior students who had used the basics of git and could pick up a new scripting language easily.

Git homework assignments:

  • Plumbing 1 – grep for strings in particular trees (apparently git grep does this automatically but no matter)
  • Plumbing 2 – make a commit history from a series of SHAs
  • Reset and Stash – 3 little scripts involving the commands
  • Merging – automatically merge two branches in a crude way
  • Rebase – rebase but show what commits change shas
  • History Rewriting – a simple interactive rebase and a use of filter branch
  • Branches and Push/Pull – pull all local branches to a remote
  • .gitconfig – write your own gitconfig

(solutions are available if you email me)

Overall, I thought it worked pretty well. I’d like to maybe refine a few of the assignments and maybe get some more in class activities. I’d even like to do an “exam” – probably not for student credit, but just so I can assess how well this is all working.

The students also generally seemed to enjoy the class (well, I had a few drop out because they didn’t want to do the homework, but that didn’t stress me out particularly much). I’ll know a little more when student evals come back in a few weeks.

My complete lecture notes are here, if you’d like to use them for something.

Anything I missed that you would cover in your 1-credit git class? Any great ideas for assignments (they should be easy to code, and exercise the commands under question well)? Comments welcome!

Looking for CS Contract Work (for me and a team of Rose-Hulman CS majors)

So this summer, I’m working on a interesting pilot project with the folks at Rose-Hulman Ventures (http://www.rhventures.org/). Basically, I’ll be acting as technical lead for a group of Rose-Hulman students working on programming contract work. So in the morning, I’ll be basically a professional programmer/mentor and in the afternoon I’ll be teaching a course for the students.

I just finished the first set of technical interviews for the students and we made offers this week. I’m actually really impressed with how the students did…I used a modified version of my old SDE interview script from my Amazon days and I was really impressed by how well the students did. Honestly, I’m not sure they’ll need all that much mentoring on my part to be productive.

Only downside: we’d ideally like at least one more contract-work software development project for the students to work on. You’d have to pay…but because of some grants we’ve got from Rose-Hulman the cost is very reasonable. Plus, you get the software and a chance to interact with some great students who presumably could be recruited for internships or full-time in future years. Plus, I’ll be on the programming team too, if that carries any weight.

If you’ve got any projects you think would be a good fit (or know someone who would) let me know! (all my contact info is here)

Good Open Source Projects for Programming/Refactoring Assignments

So CSSE375 is a Rose-Hulman course focused on refactoring (course notes here). As a result, I like to have the students make changes to existing open source projects. This gives them a little experience with codebases of a realistic size, and it makes the assignments feel a little more authentic.

I generally like Java projects that can be made to build automatically in Eclipse. Not by any means a deal breaker but Java is the language they know best so it lets me focus on the concepts easiest. Eclipse is not really a requirement but it has to build really easily because otherwise I end up debugging 45 different weirdo build problems.

Here’s a few that have worked for me:

  • Argo UML – a really big project which is great (although it makes submissions a pain). A UML editor with some very weird use of objects in places. Here’s the assignment I used – and here’s the eclipse workspace source I used in case you don’t want to check it out yourself. The force based aspect of the assignment is maybe too fussy an algorithm…if I had to do it again I might do something a little simpler.
  • Cleansheets – a great java spreadsheet that is quite reasonably designed. Builds very easily. The assignment I used was this one but I’ve since released the solution so I wouldn’t go reusing it on anything important. But I would use it again on another assignment.
  • jFTP – this one’s codebase has a LOT of duplication in it…great if you want to pratice some refactoring techniques. Here’s the assignment I used and I modified the codebase slightly to make testing harder and make the project build easily in Eclipse.
  • BORG – another large codebase, in this case a calendaring program. Unfortunately, annoying to build because students must install the lombok library. Here’s an assignment I did using it anyway.

If you’re looking for a more straightforward refactoring assignment, here’s what I started my students with – Calender Parse Part 1 & Part 2.

Programming Assignments for Programming Language Paradigms

This winter I taught a course called Programming Language Paradigms. This is a language-oriented course where students learn several interesting programming languages and discuss the various features of these languages. The goal is to learn the various paradigms of programming through actually using the languages to solve the kinds of problems that they are well suited for (you can see the complete notes for the course, if you’re interested). One of the consequences of this was that I had to develop a lot of assignments in each of the languages. Of course, I didn’t develop them from scratch – I dug around and bummed what I could from courses I found online. But there’s not as many assignments out there as there used to be, partly because I think many college courses now use Moodle and so are automatically walled off. But I figured at the very least I could contribute a few.

Prolog Assignments

Prolog turned out to be a great language to start with – absolutely different than what they had seen before, and fun to solve the problems.

  1. Maze Problem simple pathfinding, first assignment in prolog. Main thing is that it’s designed to force to you encounter infinite prolog loops earily.
  2. Word Find a program that generates all possible “word finds” for a list of words. Main thing is that it forces you to carefully manage unbound variables.
  3. Grade NLP final prolog project. In practice, it was a bit too open ended – lots of folks didn’t end up doing anything too cool. I think next time I’ll do a more traditional sentence structure NLP, plus more hints for how to structure the code. I think if I were to do it again I’d follow this assignment more closely.

Erlang Assignments

Erlang was maybe the least well-loved of the assignments, but I think that may be more due to the complexity of managing multithreaded programming.

  1. List Problems first functional-ish language so needed to give them some practice with iterators.
  2. Simple Communication in class activity where students practiced setting up multiple processes and communicating
  3. Merge sort a multi-process merge sort. Students don’t actually have to implement merging or sorting, but the communication is tricky. This one has some basic unit tests.
  4. Paxos final project, implementing the paxos algorithm in erlang. Includes some serious unit testing. But this assignment was probably too hard – I think I might do the raft algorithm next time which supposed to be simplier.

Elm Assignments

Elm was liked by folks who enjoyed making games, less liked by others.

  1. Circle following mouse simple but gets the idea of signals across
  2. Line drawing adds in the state signal
  3. Spacewar more complex state, getting ready for the final project
  4. Scrolling Video game the assignment itself seemed to work pretty well. Nobody asked to do something different than the scroller.

Other in-class activities

  1. Lua/C integration activity
  2. An in class thing about making monads I did with Haskell

I have solutions for many of these assignments as well (excluding the really open-ended ones) – as long as you’re a professor or something similar. Email me.

My students are awesome: CSSE 376 Board Games

So in my quality assurance course, I ask my students to form groups of 2-3 and build computerized versions of board games. I selected board games in particular because I knew board game logic was both understandable AND tricky enough that it could generally benefit from robust unit testing (which was what I was mainly asking them to practice for this project).

I was very happy with what my students produced. Every team worked well and reliably turned out code week after week – perhaps partly because they knew I was monitoring their github commits 🙂 . These games are really quite complex…if you look at these videos I think you’ll see tons of detailed (and tricky to implement) logic.

And…lest you think I was slacking on the testing…each of these games has greater than 75% code coverage…not at all bad when you consider the complexity of the GUIs which are mostly untested.

Anyways, check out their stuff!

CivilizationMovieFinal from Spencer Murphy on Vimeo.

Reflection on Summer 2012 GHP Classes

I’m a big believer in student feedback. Even though students often can’t articulate the source of problems, going through and reflecting is an essential part of figuring out what I want to try going forward. So even in an environment like GHP where I’m not asked to formally collect evaluations, I always do. Of course, it really helps that at GHP in particular students are relentlessly positive. Seriously my worst review this summer was “not my favorite class by any means, but still good”. I wish that’s what my worst university eval looked like.

BUT, looking at the feedback ( and ), one thing that I am struck by is how much more satisfied by student feedback that is about course content and not about me. This is something that I think the Wicked Teacher of the West said first…but I can’t find the blog post now. When I student says “It’s a really great course” that of course makes me a little happy. But when a student says “I thought it was really neat how you could prove problems are incomputable by reducing them to other incomputable problems” that makes me think I did my job. It’s always about the student’s relationship with the content, not the student’s relationship with you.

I see that a lot more in my theory of computation course than I do in my fractals class – that makes me suspect I’m doing a better job in ToC.

Theory of Computation was different this year, I think because I didn’t have the same core of super-strong students who were really loving the course. There’s definitely a class culture that develops, and I’m not yet attuned enough to think seriously about how I can help its development. The course was still good, and I think I was able to smooth out some rough edges for some students. Remaining challenging however, is the issue of the two main proof techniques we do in class: the pumping lemma and incomputability proofs. If I teach this course again I’m gonna at least crack the pumping lemma.

Fractals was better this year. I found it less stressful, and I think the students learned more. Fractal dimension seemed like a big hit this time around, so I we can explore that a little more. We kicked things off with some very simple feedback functions and Chaos – I think that helped people get on board at the get go. I think affine transformations needs more exploration discussion and play. A little tricky without computers some times.

Making Simple Fractals in R

In my GHP Fractals class this summer, I opted to write my sample programs in R. I selected R because it has very nice graphing libraries and built-in complex numbers. Overall, I was pleased with R; it definitely let me built some incredibly straightforward fractal code. It’s not as fast or pretty as other choices might have been, but it highlighted the underlying math which was most important to me.

King's Dream Strange Attractor (parameters from Chaos In Wonderland)

.

You can see an example on the left, rendered by R. The source of this particular fractal comes from Clifford Pickover’s . The graph is made by repeatedly iterating a simple function of x and y based on sine and cosine.

You can see the code in R here:

  a <- -0.966918
  b <- 2.879879
  c <- .765145
  d <- .744728
  pointsToPlot <- 100000
  
  
  x <- .1
  y <- .1
  allXs = rep(0,pointsToPlot)
  allYs = rep(0,pointsToPlot)
  for(i in 1:pointsToPlot) {
    newx <- sin(y*b) + c*sin(x*b)
    newy <- sin(x*a) + d*sin(y*a)
    x <- newx
    y <- newy
    allXs[i] <- x
    allYs[i] <- y
  }
  
  plot(allXs, allYs, pch=".", col="red",
       main="Strange Attractor: King's Dream")

Here’s a few more pretty pictures:


(Contains 7 attachments.)

So Duke Spring 2012 is finished, and grades are in; it’s time for me to become an ordinary graduate student again. But before I do that, I think it’s reasonable to reflect just a bit on how the semester went.

All and all, I am happy but not ecstatic with how my first semester turned out. In general I think students enjoyed my classes and they learned a lot (and my course feedback reflects this). I was able to try out some techniques I thought would work well, and in general I had good success. Of course it also helped that my students were almost always enthusiastic and extremely conscientious.

One main thing I learned this semester is that I have to be a little bit more careful about how I manage my time outside the classroom. As a professor, there’s a lot I can do to help students and in the beginning it was really easy to put in a lot of extra hours. Not that I mind putting in extra hours for the students, but time away from relaxing and sleeping takes it’s toll. Towards the end of the semester, I just got exhausted and then I really couldn’t put in time sometimes when I really needed to.

Well, enough vagueness. Here’s what my students said in their written feedback, crudely summarized by me:

I’ve also attached the official numerical feedback summaries below.


(Contains .)

My students are awesome (part 2): cs100

CS100 is a your basic CS2 course, providing an introduction to data structures, big O, and of course plenty of practice coding tricky problems. This course is a great favorite of mine to teach, mostly because of the office hours. It’s just fun to work with students who are just starting to get serious with Computer Science; they are still capable of having fun just getting the computer to output the right stuff.

For extra credit, we gave the student an opportunity to write a song about Computer Science. There were some super awesome submissions. One of my favorite lines is the refrain from this adaptation of Avril Lavigne’s Complicated (Noelle Suaifan):

Why’d you have to go and make Java so complicated?
I see the way you’re forgetting to import packages gets me frustrated
CompSci’s like this, you
And you code and your program implodes and takes forever to load
and you don’t insert that node and your code is the biggest mess
But promise me you’re never gonna switch your major to Art History
No, no, no

Two other great submissions:

  • Far Away From Java Code by Haoran Liu and Hanxiao Mao (lyrics)
  • Algorithms and Data Structures Theme Song (adapted from the Pokemon theme song) by Jennifer Villa and friends (lyrics)

Check out the complete list.

Pretty much all of these songs are about how difficult the assignments in CS100 are. Should I be concerned?


(Contains 2 attachments.)