GCSE · Computer Science · AQA · Spec 8525
Meaningful identifier names
Weird but true: your program would run exactly the same if every variable were called x1, x2 and x3. So why care about names? Because people have to read code.
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 the name you give an item so you can refer to it: a variable, constant, subroutine, parameter or array.
- A meaningful name describes what the item holds or does — totalScore or number_of_students, not x or t1.
- Valid means it follows the language's naming rules. Typically: no spaces, no leading digit, and no reserved keyword such as while.
Have a goYour mate Sam names a variable 3rdPrize and insists it's fine because "it reads perfectly". Will the language actually accept it?
No — it starts with a digit, so it breaks a naming rule.
"Reads perfectly" is about meaning, but the language only checks the rules, and a leading digit fails one. thirdPrize passes both.
- Exact rules vary between languages, so check the one you are using.
- Meaning and validity are separate tests: x is valid but meaningless, while player age is meaningful but invalid.
Have a goq is a variable holding a pupil's quiz score. Which of the two tests does it pass, and which does it fail?
It passes valid and fails meaningful.
A single letter breaks no rule, but nothing in q tells a reader it's a quiz score, so it isn't meaningful. quizScore passes both tests.
- Good names make code easier to read and maintain — for other programmers, and for you coming back months later.
- Debugging gets easier too: each item's role shows in its name, so you're less likely to mix one item up with another.
- Meaningful names make code partly self-documenting — fewer comments needed, but not none.
Have a goA line reads s = 0 with the comment # number of seats booked above it. Rename s so that this comment becomes unnecessary.
seatsBooked (or seats_booked).
Once the name says what the variable holds, the comment only repeats it. Meaningful names reduce the need for comments, though they don't remove it.
- Join multi-word names with one style, used consistently: camelCase (highScore) or underscores (high_score).
- Descriptive, not needlessly long. A single letter is fine only when its meaning is obvious, like a loop counter i.
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
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. Looks convincing. It isn't. 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?
What makes an identifier meaningful?
What are the two separate tests a good identifier must pass?
Why is player age not a valid identifier?
Why is 2ndPlace not a valid identifier?
Why can't a variable be called while or class in many languages?
Is x a valid identifier?
When is the single letter i an acceptable name?
How do meaningful names help when debugging?
How do meaningful names help with maintaining code?
What does 'self-documenting' code mean?
Do meaningful names remove the need for comments?
What are camelCase and underscores?
Is a longer identifier always better?
Does a program run differently if its identifiers are meaningful?
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 postedMore AQA GCSE Computer Science topics
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 29 October 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.