Revise Computingrevisecomputing.co.uk
At a glanceFeaturesStudentsPricingHow it worksFree GCSE notesExam dates
At a glanceFeaturesStudentsPricingHow it worksFree GCSE notesExam dates

Knowledge organisers / Maintainable Code

Tidy code comparison

All topicsPractise exam questions
Knowledge organiser

Maintainable Code

301.7d

Improve messy examples.

What you need to know

Tidy code uses meaningful names, consistent indentation, and helpful comments. You should be able to read messy code and rewrite it following best practices without changing its behaviour.

Key points

  • Rename single-letter variables to descriptive names
  • Add consistent indentation (4 spaces)
  • Add comments to explain purpose of sections
  • Remove unnecessary blank lines or clutter
  • Keep line length reasonable

Code examples

Messy → tidy
python
# MESSY
x=int(input())
if x>10:
 print("big")

# TIDY
user_number = int(input("Enter a number: "))
if user_number > 10:
    print("That number is big")