Museum Collection Peer Review
A developer is creating a digital catalog for a small museum. The program currently allows users to search for artifacts by entering a year. If the year matches an artifact’s creation date, the program displays the artifact’s name and a short description.
During a peer review, a colleague notes: “The search function works when I type ‘1920’, but when I type ‘1920s’ or ‘early 20th century’, the program crashes instead of showing an error message or returning zero results.”
Which concrete action best addresses the peer review comment while satisfying the requirement to handle unexpected inputs gracefully?
Write a comment in the code explaining that users should only enter numerical years when using the search function.
Modify the search function to check if the input is a valid number before attempting the search, displaying a “Please enter a valid year” message if it is not.
Update the museum’s database so that every artifact includes tags for decades and centuries, allowing the current search function to find them.
Add a feature that automatically converts any text input into the closest valid year before searching.
Question Leaderboard
Not enough data yet to show leaderboard.
