Hacker News new | ask | show | jobs
by tralarpa 2764 days ago
Your posting is already 13 hours old but I hope you still see this message :)

First of all, being sometimes involved in teaching CS to people, I like your website. You have obviously spent a lot of time on the question of how to teach people programming (the latter in the sense of "How to write a program that solves a given problem?"). I have seen textbook authors with less dedication.

However (there is always a "however" or "but"), I am wondering whether you are using the right approach for the N Queens problem. You are following a bottom-up approach. For example, on the first page you let people write a helper function "validateQueenPlacement", followed by another helper function "nextRowColumns" on page 2. For somebody who doesn't know the complete solution, it's very hard to see why you would need those two functions. Of course, you know that you will need them but you have already seen the final solution!

You are probably familar with the top-down approach by Wirth (1971) called Stepwise Refinement. I think (but I cannot prove it) that most CS educators see Stepwise Refinement as the superior approach because it encourages people to think about the problem and not the code. Why don't you let the reader write first the high-level (pseudo-)code for the backtracking:

    http://sunnyday.mit.edu/16.355/wirth-refinement.html#3
Once the reader has written the code for the highest layer, it becomes obvious what the helper functions should be, what their parameters are, and what data structures are needed. I know that Stepwise Refinement is unpopular nowadays because it forms a kind of psychological hurdle (bottom-up gives you directly small functions that you can unit-test) but I think it really helps people to guide themselves to the solution.
1 comments

Thanks for the feedback! I'll think about adding more of a high level overview in the first step, with rough pseudocode of the end result.

That said, I don't think I want to have a step where "they write pseudocode", because a lot of people would just skip that step without thinking about it.