3 ms·
Ask HN: How to Teach Refactoring?
I am teaching programming to people with little to no programming experience. The course uses Python.
I find very difficult to provide the students with a general method of refactoring, or good examples.
Do you know of a small-ish (500-3000 lines) codebase example, that is both poorly written _on purpose_ and easy to understand?
- ilaksh 3y agoRefactoring is not a beginner skill. Ask Claude 3 or ChatGPT to give you a few examples with like 5-15 lines of code. But don't give them that until they have some experience. Code isn't easy to understand for beginners. They need practice reading code. Giving a beginner 1500 lines of code to refactor is ludicrous.
- fdeage 3y agoThey have been programming for two months so they are not total beginners, they just have no notion of best practices. They already wrote two 300-line programs. The goal would be to have them read a codebase they didn't write, and optimize it. I'm not looking for expert refactoring or sophisticated design patterns (they haven't even touched OOP), I just want to show them simple ways to improve their code.