OOP anti-patterns 00:00:00 Make a prediction You will identify a design smell through the pain it causes and make one behaviour-preserving refactor that can be tested. One checkout test has to initialize a warehouse, a bank, an email server and an audit database just to check that an empty basket is rejected. What is that test setup telling you? Too many unrelated responsibilities or hard-wired collaborators are passing through one object. Move the stock rule and receipt delivery to appropriate owners while preserving the visible purchase behaviour. 00:00:33 Max and the trunk A trunk contains all the household tools. Every small repair requires unpacking it, and a wet brush can spoil the measuring tape. Sorting by what is used together keeps each job manageable. The smell matters because ordinary changes and tests become unnecessarily difficult. Refactor one responsibility, then prove the original use case still behaves correctly. An anti-pattern is a repeated answer to a repeated problem that seems good at first and makes things worse later. The seems good part matters: nobody chooses a god object. It grows, one convenient method at a time. A name makes a talk short. God object says in two words: too many reasons to change, everyone edits it, nobody can test it. 00:01:23 Shrink a checkout god object One checkout class validates stock, talks to the bank, sends mail and writes the audit log. Any small change requires an elaborate test setup. Move stock ownership to inventory and message delivery to a sender. Keep checkout responsible for sequencing the purchase. Test an out-of-stock order. No charge should occur and no receipt should be sent. The extracted responsibilities make the observation easier, without a class for every line. Place an order for an unavailable item. The stock decision should stop the flow before a charge or receipt exists. Extracting that decision with its inputs lets a focused test prove the failure case. Renaming the giant owner to service leaves the same coupling. 00:02:11 Refactor for real behaviour A user object with only getters leaves discount and eligibility rules copied across several services. Put one rule with the data that owns it and remove the duplicate calls. Creating more getters would increase access while doing nothing to protect the rule. Find two callers independently checking a booking's status before canceling it. Change the allowed cancellation state. If both need the same edit, move the decision next to the status and send a cancellation command. The next test can observe one authoritative result. Splitting a large class into ten classes that still share one writable global object changes the diagram more than the behaviour. If a cohesive object protects one substantial invariant, size alone is insufficient evidence that it must be split. PMD. The Java design rules include GodClass, which combines measures of size, cohesion and use of foreign data. The CPD tool finds copied code. ESLint. complexity limits the number of paths in a function and no-magic-numbers asks for named constants. Both have options, because the right limit differs. 00:03:24 Try an interview follow-up Leadership asks for a rewrite of a big ball of mud. Your answer? I would show where change hurts by size times commits, and propose a gradual replacement behind a front with visible progress: calls left on the old path. A rewrite stops features and must match behaviour nobody has written down. I would agree to it only for a small part with a clear contract. A large booking manager calculates refunds, sends email and edits reservations. Pick a cancellation and trace which facts are needed to calculate its refund. Extract that calculation with an input and result you can test. Keep the workflow together until another responsibility has an equally clear boundary. 00:04:09 What to take with you An anti-pattern seems helpful and costs later. Name it, name its cost, and repair in small steps under tests. God object: find groups of methods that use the same fields, and extract the smallest group first. Keep the old name as a thin front until callers have moved.