Ir al contenido

God Class (ARCH4189)

Esta página aún no está disponible en tu idioma.

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.

class UserManager {
void createUser() {}
void deleteUser() {}
void sendEmail() {}
void renderInvoicePdf() {}
void chargeCard() {}
void exportCsv() {}
// ...dozens of fields, dozens of unrelated methods
}
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.