GCSE · Computer Science · AQA · Spec 8525

Meaningful identifier names

Your program would run exactly the same if every variable were called x1, x2 and x3. So why do names matter? Because people, not computers, have to read code.

Computer Science · Identifiers

Two tests for every name

An identifier is the name you give something in a program — a variable, a constant, a subroutine, a parameter or an array. Each name below comes with the job it has to do. Tick every set it belongs to. MEANINGFUL: a reader can tell what the item holds or does. VALID: it follows the usual rules — no spaces, it doesn't start with a digit, it uses only letters, digits and underscores, and it isn't a keyword the language already uses (such as if, while, for or class).

  • A Meaningful — says what it holds or does
  • B Valid — follows the naming rules
  1. totalScore — a variable holding the running total of points
  2. x — a parameter that receives a player's age
  3. t1 — a variable holding a customer's email address
  4. player age — a variable holding a player's age
  5. 2ndPlace — a variable holding the runner-up's name
  6. class — a variable holding a pupil's form group, such as 10B
  7. test-marks — an array holding ten test marks
  8. MAX_LIVES — a constant holding the most lives a player can have
  9. calculateAverage — a subroutine that works out the mean of some marks
  10. doStuff — a subroutine that checks a password is long enough
  11. i — the counter in a short loop that counts from 1 to 10
  12. 2a — a variable holding the number of seats left on a bus

The same line, named two ways

Cryptic namesvsMeaningful names

Both versions do exactly the same thing when they run. Read down the rows and ask: which one could you fix in a hurry?

Focus

The line of code

Cryptic names

t1 = t1 + p * q

Meaningful names

totalCost = totalCost + price * quantity

The insight

Same calculation, same result. Only the names have changed.

Can you tell what it does?

Cryptic names

Only by guessing. Is p a price? A percentage? A player?

Meaningful names

Yes — it adds the cost of this item to a running total.

Adding a delivery charge later

Cryptic names

First you have to work out which letter is the total.

Meaningful names

You can see straight away which variable to change.

Another programmer picks it up

Cryptic names

They have to trace the program to decode every name.

Meaningful names

They can read it almost like a sentence.

You, six months later

Cryptic names

You've forgotten what t1 meant too.

Meaningful names

The names still remind you.

Computer Science · Debugging

Find the mix-up

This program should work out the cost of a cinema trip for 2 adults and 3 children. t1 is the adult ticket price, t2 is the child ticket price, n1 is the number of adults and n2 is the number of children. It outputs 47.5 instead of 37. Which line uses the wrong item?

A program with one bug — which line goes wrong?

Computer Science · Identifiers

What do good names really buy you?

Mia has renamed every variable, constant and subroutine in her program so that each name says what it holds or does.

Which is closest to what you think about Mia's program now?
How sure are you?

Computer Science · Your turn

Rename it yourself

a = 0 FOR b = 1 TO 5 c = INPUT a = a + c ENDFOR d = a / 5 OUTPUT d

This program reads five test marks and outputs their mean. Rewrite it, replacing a, c and d with meaningful identifier names. Use at least one name made of two or more words. (You may keep b as a loop counter or rename it.) [4 marks]

0 words · your answer stays on this page and is not sent anywhere.

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

A good name passes two separate tests: it tells a person what the thing is, and it follows the language's rules.

What you need to know

  • An identifier is a name for an item in a program: a variable, constant, subroutine, parameter or array.
  • A meaningful identifier describes what the item holds or what it does, e.g. totalScore rather than x.
  • Typical naming rules: no spaces, can't start with a digit, only letters, digits and underscores, and can't be a keyword such as if or while. Exact rules vary between languages.
  • A name can be valid but not meaningful (x, t1) or meaningful but not valid (player age, 2ndPlace).
  • Meaningful names make code easier to read, maintain and debug — for other programmers and for you later — and reduce errors from mixing items up.
  • Meaningful names make code partly self-documenting: fewer comments are needed, but not none.
  • Join multi-word names with one style used consistently: camelCase (totalScore) or underscores (total_score).

The big picture

An identifier is the name given to an item in a program, such as a variable, constant, subroutine, parameter or array. A good identifier passes two separate tests: it is meaningful (it describes what the item holds or does) and it is valid (it follows the language's naming rules). The computer only enforces validity, but meaningful names make code easier for people to read, maintain and debug, and make it partly self-documenting.

Key points

1Two tests, two judges: the computer checks whether a name is valid; only people can judge whether it is meaningful.
2i is an accepted exception: as the counter of a short loop it is a convention every programmer recognises.
3Descriptive beats both cryptic and needlessly long — totalScore, not t or theTotalScoreOfThePlayerSoFar.
4A program running without errors proves its names are valid, not that they are meaningful.

Worked example

Problem

Suggest a meaningful, valid identifier for (a) a variable storing the number of tickets sold for a concert, and (b) a subroutine that checks whether a username is already taken.

⚠ Watch out

Thinking a name must be fine because the program runs. Running without an error only proves the name is VALID. It says nothing about whether it's MEANINGFUL — x and doStuff run perfectly well and tell a reader nothing.

🧠

Memory hook

The computer checks the RULES; people check the MEANING. A good name has to satisfy both.

✓

Check yourself

Without looking back: write down one identifier that is valid but not meaningful, and one that is meaningful but not valid. For the second one, say which naming rule it breaks.

Flashcards

(15)
What is an identifier?
The name given to an item in a program, such as a variable, constant, subroutine, parameter or array.
What makes an identifier meaningful?
It describes what the item holds or what it does, so a reader can tell its purpose from the name.
What are the two separate tests a good identifier must pass?
It must be meaningful (makes sense to a person) and valid (follows the language's naming rules).
Why is player age not a valid identifier?
It contains a space. Write it as playerAge or player_age.
Why is 2ndPlace not a valid identifier?
Identifiers can't start with a digit. secondPlace is fine.
Why can't a variable be called while or class in many languages?
They are keywords the language already uses, so they can't be used as names.
Is x a valid identifier?
Yes — it follows the rules. It just usually isn't meaningful, because it doesn't say what it holds.
When is the single letter i an acceptable name?
As the counter in a short loop — it's a widely understood convention, so readers know what it is.
How do meaningful names help when debugging?
They make it easier to spot when the wrong item has been used, so there are fewer errors from mixing items up.
How do meaningful names help with maintaining code?
Code is easier to understand, so it can be changed safely — by other programmers or by the original programmer coming back later.
What does 'self-documenting' code mean?
Code whose names explain much of what it does, so it needs fewer comments.
Do meaningful names remove the need for comments?
No — they reduce it. Comments can still explain things a name can't, such as why the code does something.
What are camelCase and underscores?
Two ways to join words in a name: totalScore (camelCase) or total_score (underscores). Pick one and use it consistently.
Is a longer identifier always better?
No. Aim for descriptive but not needlessly long — long names are slow to read and easy to mistype.
Does a program run differently if its identifiers are meaningful?
No. It runs exactly the same. Meaningful names are for the people who read the code, not for the computer.

Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.

Learning with Lightbulb is opening soon

You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.

Keep me posted

More AQA GCSE Computer Science topics

See the full AQA Computer Science curriculum →

How this lesson was checked. This AQA GCSE Computer Science (specification 8525)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 30 September 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.