God Class (ARCH4189)
Key java.quality.god-class · Severity info · Category quality
Classes with too many methods and fields bundle unrelated responsibilities, lowering cohesion and making maintenance hard. Split the responsibilities into separate classes.
Incorrect
Section titled “Incorrect”class UserManager { void createUser() {} void deleteUser() {} void sendEmail() {} void renderInvoicePdf() {} void chargeCard() {} void exportCsv() {} // ...dozens of fields, dozens of unrelated methods}Correct
Section titled “Correct”class UserService { void createUser() {} void deleteUser() {} }class EmailService { void send() {} }class InvoiceService { void renderPdf() {} }class PaymentService { void chargeCard() {} }Split the class into a few cohesive single-responsibility classes and wire them together via composition.