Question 1 Report
Read the information below about a language-learning app. The app chooses a new word for each player by calling pickWord(level). The function selects a word from the correct list and returns it. Another procedure, showHint(word), displays the first and last letters of that returned word. The developer uses meaningful subroutine names so that another programmer can understand the main program without reading every command inside the subroutines. A fault report says that a level 3 player is sometimes given a word from level 1.
(a) Explain how meaningful names such as pickWord and showHint improve the readability of code. [2]
(b) Explain which subroutine should be investigated first for the reported fault. [1]
(a) Meaningful names state the purpose of each block: pickWord selects a word, while showHint displays a hint. A programmer can therefore follow the main program without inspecting every command inside each subroutine, making maintenance easier. [2]
(b) Investigate pickWord(level) first, because it selects the word list and returns the chosen word. It is the subroutine responsible for choosing a level-appropriate word. [1]
Everything you need to excel in your exams