Skip to content

What Makes Code Good? Readability and Style

Beginning of the lesson

What Makes Code Good?

Readability and style: writing code that people can read, not just computers

Big Idea: Code that works is only half the job. Good code is also easy for a human to read and change. That means clear names, small tidy pieces, and neat structure — so the next person (maybe future you!) can understand it fast.
By the end you will be able to:
  • explain why "it works" is not enough,
  • give things clear names,
  • break a big job into small, tidy pieces,
  • keep the structure neat and easy to follow.

1. Code is read by people

A computer does not care if your code is messy. It follows any correct steps. But humans read code too — to fix bugs, to add new parts, or to learn how it works. Most code is read many more times than it is written!

So "good code" means two things: it works, and it is easy to read and change. If code works but nobody can understand it, it is hard to fix later. Writing clearly is a kindness to the next reader.

2. Clear names

Every box (place to keep a value) and every helper should have a name that says what it is. A good name explains its job so you do not have to guess.

Unclear nameClear name
x score
n numberOfPlayers
doStuff addPoints
a2 playerName

Think of names as labels on boxes. A box labelled "score" is easy to find. A box labelled "x" makes you open it just to remember what is inside.

Continue this lesson on YourAIZone

The full lesson has the complete explanation, worked examples, common mistakes, tests with instant checking and an AI tutor. Start right away as a guest, or create an account to keep your progress.

In the full lesson

  • The complete explanation
  • Worked examples
  • Common mistakes and how to avoid them
  • Test questions: 15
  • AI tutor that answers questions about the topic
  • Progress tracking for students, parents and teachers