Skip to content

God class (ARCH2189)

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.

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): ...
class App:
def __init__(self, db, mailer, billing):
self.db = db
self.mailer = mailer
self.billing = billing

Split responsibilities into smaller single-purpose collaborating classes.