Programming Pedagogy and Writing Pedagogy
As programming instruction is becoming more and more vital to economic growth and opportunity, and as more programming instruction is moving out of traditional schools and universities and into non-traditional learning institutions (coding bootcamps, MOOCs, and online platforms like Codecademy, and freecodecamp), it is worthwhile to reflect on the different programming pedagogies that exist.
I’ll write more on this later, but I’ll start by reviewing some similarities that I’ve noticed between best practices in teaching writing and teaching coding. Prior to learning to code, I taught college composition classes for two years, so I came into this with some general ideas about what makes instruction effective.
Teaching writing and teaching programming are in fact more similar than one might expect. Writing and coding are ultimately both process-oriented skills, and are best taught in a manner that pays explicit attention to how to revise (or, in the case of coding, refactor) your work, and encourages meta-cognitive reflection to help the student better understand his or her own process-based strengths and weaknesses.
Process Oriented Learning
- Learning to write and learning to code are both process oriented. Though a certain amount of domain-specific knowledge is necessary in both fields, these are not fields where mastery means being able to understand and recall a large body of information. You can know a lot about programming languages, but unless you’ve put in the work to practice programming by writing a lot of code, that won’t make you a strong programmer. Similarly, you can be an avid reader who has studied writing carefully, but you likely won’t be a strong writer until you have a lot of practice putting words on the page.
Rewriting and Refactoring
- Writing better quality essays and code depends on your skill at — and commitment to — rewriting/refactoring. College composition instructors often emphasize that even published writers produce shitty first drafts, and that learning to write better consists of becoming an objective observer of your own work, and being willing to discard and replace written material as you rewrite and revise your work. Similarly, great code is rarely written on the first attempt. Code must be refactored to be clearer, more readable, more modular, and more consistent with the design pattern of the overall architecture of the project. Programmers who refuse to refactor their code will quickly accumulate technical debt.
Teaching Rewriting and Refactoring
- Revising written work and debugging/refactoring code based on feedback is a skill that must be regularly practiced. These are not skills that will just be passively acquired over time as the student writes more prose or code, but instead core learning outcomes that should be made central to the curriculum design.
- In the writing classroom, this is taught through peer review and writing workshops, and which can then be reinforced by a grading system that rewards revision from draft to draft. Interpreting the sometimes-contradictory feedback of others, who sometimes represent distinct different audiences for the eventual piece, to come up with plan for revision is not a straightforward process, and one that needs to be modeled and taught through group workshops.
- In programming, this feedback comes from different sources: (A) the computer executing the student’s code (via error messages, logs, and tests) and (B) other people, through pair programming and code reviews.
- A strong programmer is someone who can debug and refactor their own code. They know how to read and interpret error messages, and research errors in order to identify and isolate problems in the execution of their code. They know how to translate feedback from other people into actionable plans to make their code more readable and modular. These skills and practices need to be made central to the programming curriculum just as rewriting and revision is central to teaching writing.
The Role of Metacognition in Learning
- Engaging in metacognitive reflection— or, getting students to think about their own brainstorming and writing process — is a staple of current college composition curricula. Students might be asked to answer such prompts: What have they learned through the semester? How did they identify research sources? What strategies for writing and revising worked well for them individually and what didn’t? What are their strengths and weaknesses as a writer?
- Getting students to be more self-aware about their writing practice improves their self-regulation of their own writing habits. This can be mirrored in programming when agile development patterns are followed for curriculum design and student projects. Each daily stand-up and each retrospective after a “sprint” are a time for students to engage in metacognitive reflection about their coding practice that should help them understand their strengths and weaknesses and transition towards more self-aware and self-sufficient programmers.