God class (ARCH2189)
Esta página aún no está disponible en tu idioma.
Key python.quality.god-class · Severity warning · Category quality
Classes holding many methods and fields do too much, have low cohesion, and are hard to change. Split their responsibilities into focused classes.
Incorrect
Section titled “Incorrect”class App: def parse_config(self): ... def connect_db(self): ... def render_html(self): ... def send_email(self): ... def charge_card(self): ... def export_pdf(self): ...Correct
Section titled “Correct”class App: def __init__(self, db, mailer, billing): self.db = db self.mailer = mailer self.billing = billingSplit responsibilities into smaller single-purpose collaborating classes.