Tutorial-7
Question1: You joined a team maintaining an E-commerce Order Processing Module. Recently
reported production issues:
• Orders sometimes created with wrong total amount
• System crashes when cart is empty
• Code is hard to maintain and extend
• Payment logic repeated in multiple places
• Performance slow for large cart sizes
You are given the following existing code.
Existing Production Code
PART A: Create a Code Checklist and identify at least 8 checklist violations in the given code.
PART B: Perform Code Review and answer:
• Find logical bugs
• Find performance improvement scope
• Suggest design improvements
• Suggest test cases
PART C: Refactor code to:
• Improve readability
• Improve modularity
• Make payment logic extensible
Question 2: You are building a recommendation engine. Need to check if any two prices sum to
target.
• Find time complexity
• Optimize using better data structure
• Write optimized code
• Compare time complexity
Question 3: The following question shows payment processing system which gives bad code,
optimization task, design pattern task
Bad Code
Optimization Task
• Remove repeated printing logic
• Improve extensibility
Design Pattern Task
Apply Strategy Pattern:
• Create base Payment interface
• Create derived payment classes