God Class (ARCH6189)
هذا المحتوى غير متوفر بلغتك بعد.
Key ruby.quality.god-class · Severity warning · Category quality
A class that accumulates too many methods and fields takes on unrelated responsibilities; it has low cohesion and is hard to test and evolve.
Incorrect
Section titled “Incorrect”class Order def calculate_total; end def charge_card; end def send_email; end def generate_pdf; end def update_inventory; end def post_to_ledger; end def notify_shipping; endendCorrect
Section titled “Correct”class Order def calculate_total; endend
class OrderPayment; def charge; end; endclass OrderNotifier; def send_email; end; endclass Invoice; def generate_pdf; end; endSplit the class by responsibility into smaller, single-purpose, cohesive classes.