Bird
0
0

What is wrong with this hold release logic?

medium📝 Analysis Q7 of 15
LLD - Design — Library Management System
What is wrong with this hold release logic?
def release_hold(hold_id):
    hold = get_hold(hold_id)
    if hold.is_expired():
        return 'Cannot release expired hold'
    delete_hold(hold_id)
Aget_hold function is missing
BExpired holds should be released, not blocked
CFunction does not return anything after delete_hold
Ddelete_hold should be called before checking expiry
Step-by-Step Solution
Solution:
  1. Step 1: Understand hold release purpose

    Expired holds must be released to free resources.
  2. Step 2: Analyze logic blocking expired hold release

    Code prevents releasing expired holds, which is incorrect.
  3. Final Answer:

    Expired holds should be released, not blocked -> Option B
  4. Quick Check:

    Expired holds must be released [OK]
Quick Trick: Always release expired holds to free resources [OK]
Common Mistakes:
MISTAKES
  • Blocking release of expired holds
  • Misordering delete and checks
  • Ignoring return values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes