Hacker News new | ask | show | jobs
by sevensor 789 days ago
It's a pain, but you can definitely learn a lot from fixing a bad codebase. For that, I recommend trying to write type annotations and get the whole thing to type-check. I've found that bad codebases end up having very complex type annotations because their authors actually contradict themselves. One of my personal favorites in Python is mixing strings and UUIDs as dictionary keys. This positively guarantees a fun afternoon.

Edit: speling

2 comments

Another learning point is being sensitive to your psychology / mental energy. I can start with high quality well named, well abstracted code.. but after two weeks I find myself writing shitty code.. and having a hard time realising I should stop, take a pause, take a step back instead of piling on.
Pre-commit hooks help me immensely with this. At least there's some limits on crappiness.
I'd start with pyflakes and ruff check/format as step 0. Much easier to get started, and will have fixed a lot of stuff quickly. Next, add types.