Last one out of the Kinjaverse, turn out the lights.

Why I don't post coding solutions

So for those who don't know, I teach C++ to baby engineers and the occasional stray math, physics, econ or undecided major. I use the term baby engineer affectionately because I was one, at the same school even, and so I'm intimately familiar with their usual method of "learning" and that's why I don't post coding solutions.

Copy/paste is not a coding strategy

Many of my students tend to approach problems in an almost paint by numbers sort of way. They're shown a problem in class, the professor shows the steps in the solution, they're given the same problem with different numbers, they apply the steps and get the right answer. They've managed to altogether bypass why they do those steps and think that just learning 'em is good enough.


This is a terrible idea in a typical engineering course, but it gets even worse in computer science. They see keywords in the question like "if" and quickly scramble to find all previous homework where they used if statements and start throwing code at the problem until something sticks. They're trying to emulate the sort of step 1, step 2...approach to problem solving that's gotten them pretty far in their other courses.

Reasoning about the problem is

I'm trying to get them to break that step 1, step 2 habit and instead think about the problem-what it's really asking, what's the underlying logic, can they flow chart and diagram it? I'm trying to encourage them to have a plan for tackling the problem before they write a single line, instead of trying to code their way to a solution.

There's no right solution

I withhold solutions because I don't want them thinking that there's only one way to solve a coding problem. Some ways are better and more elegant and whatever else, sure-but the beautiful thing about code is that it's amazingly easy to figure out if you've done it right. If the code works, you've done the problem correctly. That's about it. We can get into better test cases and cleaner solutions - which I'll happily talk to my students about 'til their ears turn blue-but code itself is pretty much self verifying.


Solutions can be more hinder than help

My exams are super lax-open book, open notes, open blackboard, open github where I post various code examples-and watching them, I'm always tempted to go a bit more strict for their own good. I see students spend a lot of time with some code open and I can see the gears in their head trying to fit the problem to the code sample they have open rather than trying to fit the concept implemented by this code to their problem.


Now I'll be the first to admit that a lot of this is just due to inexperience. As they code more, the concepts should start sinking in enough that they'll be able to intuit how they work and should be applied to a problem. And then it'll all come full circle as it'll become useful to seek out other people's code and see how they solved a similar problem and how to use some tricky piece of code and all the other things that send us all flying to stackoverflow.

But until they develop the tools and the desire to figure out what the code solutions they're finding do, I'm going to continue not providing solutions in a vain attempt to motivate them to implement their own solutions.


Disclaimer: Yes, I fully expect people will read this and go "well, you obviously suck as a teacher", which yeah... Most of my course materials are on github (everything 'cept homework and quizzes/exams), I use weekly auto graded homework and quizzes to provide immediate feedback, and piazza to encourage out of class discussions. I'd love to hear suggestions on what you'd do differently. I already stole someone's idea about offering extra credit to students for accepted pull requests.

Share This Story