Subroutines

    AQA
    GCSE

    Subroutines are the fundamental units of modular programming, enabling the encapsulation of code into named blocks (procedures and functions) to promote reusability, maintainability, and abstraction. Candidates must distinguish between procedures, which execute a sequence of actions, and functions, which return a value to the calling statement, while demonstrating precise control over data flow via parameters and arguments. A critical component of assessment is the mastery of variable scope, specifically the distinction between local and global variables and the implications of 'shadowing' within the execution stack. High-level responses will further differentiate between passing parameters by value and by reference, explaining the impact on memory and original data integrity.

    0
    Objectives
    3
    Exam Tips
    3
    Pitfalls
    4
    Key Terms
    4
    Mark Points

    What You Need to Demonstrate

    Key skills and knowledge for this topic

    • Award 1 mark for explaining that subroutines improve code maintainability by allowing code reuse and reducing duplication
    • Award 1 mark for correctly identifying that local variables are only accessible within the subroutine in which they are declared
    • Credit responses that distinguish between parameters (variables defined in the subroutine header) and arguments (actual values passed during the call)
    • Award 1 mark for writing a syntactically correct return statement that passes the result back to the calling program

    Marking Points

    Key points examiners look for in your answers

    • Award 1 mark for explaining that subroutines improve code maintainability by allowing code reuse and reducing duplication
    • Award 1 mark for correctly identifying that local variables are only accessible within the subroutine in which they are declared
    • Credit responses that distinguish between parameters (variables defined in the subroutine header) and arguments (actual values passed during the call)
    • Award 1 mark for writing a syntactically correct return statement that passes the result back to the calling program

    Examiner Tips

    Expert advice for maximising your marks

    • 💡When writing a function in pseudocode or Python, explicitly check if the question requires a value to be returned; if so, a 'return' statement is mandatory
    • 💡In trace table questions involving subroutines, create a new column or section for local variables to clearly separate them from global variables
    • 💡Use descriptive identifiers for subroutines (e.g., 'calculate_average') to demonstrate good programming practice, which is often credited in holistic marking bands

    Common Mistakes

    Pitfalls to avoid in your exam answers

    • Confusing 'print' with 'return'; candidates often output a value to the screen inside a function rather than returning it to the main program for further processing
    • Misunderstanding scope rules, specifically attempting to access a local variable from the main program or a different subroutine
    • Failing to assign the return value of a function to a variable in the calling code, resulting in the data being lost

    Key Terminology

    Essential terms to know

    Likely Command Words

    How questions on this topic are typically asked

    Define
    Explain
    Develop
    Trace
    Compare

    Practical Links

    Related required practicals

    • {"code":"Programming Project Skills","title":"Modular Design","relevance":"Decomposing a complex problem into subroutines for the NEA/practical programming tasks"}

    Ready to test yourself?

    Practice questions tailored to this topic