Lesson 87: Refactoring & Cleanup
Module 9: The Master Capstone — Building an Industry-Grade Framework
The Junior Trap: “It Works On My Machine”
Imagine handing your car keys to a mechanic who says, “I don’t label my tools, I just remember where they are.” That’s fine — until they get sick, or until you hire a second mechanic. Your UQAP codebase is no different.
A junior dev or transitioning manual tester usually writes code like this:
# junior_trap.py
def login(d, u, p):
d.find_element("id", "user").send_keys(u)
d.find_element("id", "pass").send_keys(p)
d.find_element("id", "btn").click()
return True
def check_dashboard(d,user_name,timeout=10):
import time
time.sleep(timeout)
el = d.find_element("class name","welcome")
if user_name in el.text:
return True
return False
This code works. It will pass a demo. It will also:
Break the moment a second engineer edits it (variable
d? what type is that?)Fail mypy and flake8 CI gates, blocking the entire merge queue
Create silent type bugs — what if
timeoutreceives"10"(a string)?Make code reviews 3× slower because nobody knows the contract of each function
This is not a style debate. In a production CI/CD pipeline, unformatted, untyped code is a build failure.



