3

Teaching how to code is broken

 2 years ago
source link: https://neil.computer/notes/teaching-how-to-code-is-broken/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Teaching how to code is broken

Croneberg_and_Stokoe-1.png

Typically:

  • Chapter 1: Types
  • Chapter 2: Variables
  • Chapter 3: Operators/Math
  • Chapter 4: Control structures
  • Chapter 5: Arrays
  • Chapter 6: Functions
  • Chapter 7: Structs
  • Chapter 8: Classes and Objects
  • Chapter 9: Methods
  • Chapter 10: Inheritance and Polymorphism
  • Chapter 11: Some advanced thing X
  • Chapter 12: Some esoteric thing Y
  • Chapter 13: No one reaches the end so let's introduce concurrency here

This is fine for a reference book for an experienced professional. It is a terrible format for tutorials or any guidance material that intends to teach people how to code, specifically beginners.

Why? Because none of these chapters answer the most important question a reader has, the entire time, WHY!? Why is all this important and what problems does it solve? When should I use this thing that I learned? Imagine if aliens landed on earth and we teach them everything about the shape of a fork, its material, how its made, typical ways of holding it, various shapes of forks, its history, and etymology, but never tell them that a fork is used to pick up food and stick it in the mouth.

Teaching how to code should be about problem-solving and effectively using the tools of a programming language to solve it. Say for example modeling a card game. Even better if the example is a continuous improvement starting from the very basics, hard coding stuff, and then increasing the scope as follows:

  • Chapter 1: Cards (Constants, literals - hard code all cards)
  • Chapter 2: Suits (String concatenation, Int vs literal string)
  • Chapter 3: Ordered Ranks (Arrays, Variables to store each suit)
  • Chapter 4: Deck (Multidimensional arrays)
  • Chapter 5: Shuffling (Loops, Control flow, Member access, Assignment)
  • Chapter 6: Reusability of Shuffling algorithm (Functions, Pass by Value/Reference)
  • Chapter 7: Modeling a card game (I/O, Cards as Objects, Classes/Structs)
  • Chapter 8: Modeling a complex card game (Abstraction, Inheritance, Polymorphic behavior, Overriding methods, etc.)
  • Chapter 9: Multiplayer card game (Sockets and Networking, Server-Client communication, Concurrency)

There are very few resources out there that truly embrace this type of teaching – e.g. the absolutely brilliant Nature of Code for beginners. Another one for experienced software engineers is Architecture Patterns with Python (models an e-commerce business from scratch).

I've found that modeling or simulating something real like a card game is very effective. It teaches students about how to translate a real-world situation/problem/thing/phenomenon into code. Teaches them about assumptions and limitations of the model they've built. Also, it teaches them about how to interrogate requirements imposed by the real world through simplification/abstraction or simply rejecting some aspects of it as "Too complex, costly and impractical to model with no real benefit or a clear use case" :-).


Image credit: https://commons.wikimedia.org/wiki/File:Croneberg_and_Stokoe.png Deafhistory101, CC BY-SA 4.0 https://creativecommons.org/licenses/by-sa/4.0, via Wikimedia Commons


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK