OOP anti-patterns
medium 50 minAn anti-pattern is a common answer that looks helpful and costs more than it gives: the god object, spaghetti code, copy and paste, the golden hammer, cargo cult and early optimization.
Watch lesson4:28
Where it shows up
The same pattern appears across everyday software.
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.
Pylint
Refactoring messages such as too-many-arguments point at long parameter lists, with a limit that a project can set.
SonarQube
Reports duplication, cyclomatic and cognitive complexity, and shows them over time.
TypeScript noImplicitAny
A compiler option that refuses to guess any, so missing types are seen.
C++ Core Guidelines
R.11 says to avoid calling new and delete explicitly. Ownership should stand in the type.
GitHub Scientist
A Ruby library for refactoring critical paths: it runs old and new code, returns the old answer and publishes differences.
Strangler fig
Martin Fowler's name for replacing an old system gradually: new code grows around it until the old part can go.
Go proverbs
One says: a little copying is better than a little dependency. A reminder that removing every copy has a price.
Refactoring catalogue
The online catalogue lists the repairs by name, such as Extract Class, Move Function and Introduce Parameter Object.