"From Calculators to Robots – Building a QA Team with OOP"
Theme: QA Shop Architecture
🛍️ "Imagine we're setting up a virtual QA shop. We need calculators for discounts, calendars for delivery dates, workers (objects) to do jobs, and managers (classes) to control them. Some workers have special roles (inheritance). Today, we'll become the architects of this QA shop."
Built-in object for calculations.
QA Shop needs a calculator for prices, discounts, random IDs.
👉 If Math.random() returns 0.3456, what is the range of Math.floor(Math.random() * 10)?
Answer: Range is 0 to 9 (inclusive)
JS object to work with dates/times.
QA Shop needs a calendar to check order vs delivery date.
👉 What happens if you create new Date("2025-13-01")?
Answer: Invalid date - month 13 doesn't exist!
Class = blueprint, Object = instance.
In QA Shop, we hire workers (objects) using a job description (class).
Each product card in OpenCart can be represented as an object.
👉 What happens if you call laptop.discount() when no such method exists?
Answer: TypeError: laptop.discount is not a function
Special method in class → initializes object properties.
"When a new QA joins the shop, HR (constructor) sets up their desk: username, role, laptop. If HR forgets, they just enter as a blank worker."
"Default constructor = worker comes in with no setup, still works but no details."
"Custom constructor = worker gets proper badge, system login, role defined."
👉 If you don't call super() in child class constructor, what happens?
Answer: ReferenceError: Must call super constructor in derived class
One class extends another, reusing logic.
QA Shop has workers → some are Admin QAs, others Automation QAs.
👉 What error if you try c1.manageOrders()?
Answer: TypeError: c1.manageOrders is not a function