Programming foundations

Stage 5 · Lesson 3 of 10

Naming and small functions

Object-oriented design and clean code

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

Practise

  • Request mentoring on a solved exercise and ask specifically about naming and structure

Keep handy

  • Fast test runner for Node.js projects; the getting started page is all you need now

Also worth your time

Mark this stage as not done?