Stage 5 · Lesson 3 of 10
Naming and small functions
Code is read far more often than it is written, so matters, and names do most of the explaining. A good name says what something is or does: remaining_budget, not rb or data2; is_expired(), not check(). A should do one thing at one level of detail.
It should be short enough to read without scrolling, and have a name that makes a comment unnecessary. If a function needs "and" in its name, or you want a comment above each block inside it, split it. The opposite trap is dozens of three-line functions with vague names, which are as hard to follow as one long one. Rename freely as you learn what the code is really doing.
A question to check yourself, an AI practice session and 1 cheat sheet entry come when you add the roadmap to your account. Add it
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking SOLID Design Principles
Design Gurus · Beginner · $50 one-time
Five principles with code examples, including when applying them makes code worse
- GuideFreeRefactoring.Guru: Code Smells and Refactoring
Refactoring.Guru · Beginner
Free catalogue of code smells and the small refactorings that fix each one