Junior — Senior
Optimization of manager interaction with work objects
livecode
Task condition
Question: What does the presented code snippet do, and what ways are there to improve it? In the code, the Supervisor class (formerly Manager) creates two worker instances — WorkerA and WorkerB (formerly Worker1 and Worker2) — and sequentially calls the process method on each of them. It is necessary to analyze the current implementation and suggest options to enhance the readability, extensibility, and testability of the code.
class WorkerA:
def __init__(self):
pass
def process(self):
pass
class WorkerB:
def __init__(self):
pass
def process(self):
pass
class Supervisor:
def __init__(self):
self.w1 = WorkerA()
self.w2 = WorkerB()
def run_jobs(self):
for w in (self.w1, self.w2):
w.process()
s = Supervisor()
s.run_jobs()