Design Analysis
Design Antipatterns in Legacy Code
A comprehensive catalog of design antipatterns observed in PHP legacy codebases from the e-commerce sector, with strategies for identification and strangulation.
20 Categories
Antipatterns organized across architecture, security, database, performance and socio-technical dimensions.
100+ Antipatterns
Detailed documentation of each antipattern with generic illustrative examples.
Strangulation Strategy
Each antipattern includes guidance on how to identify and gradually eliminate it from legacy systems.
Legacy codebases accumulate design antipatterns over years of incremental changes, team turnover and pressure to deliver features quickly.
This project documents antipatterns observed across multiple PHP legacy codebases in the e-commerce sector. All code examples are generic and invented, inspired by real industry patterns. No code belongs to a real system.
Purpose
The goal is to identify, document and learn how to strangle each antipattern with illustrative examples. This catalog serves as a reference for developers working with legacy systems.
- Recognize antipatterns in existing codebases
- Understand the root causes and consequences of each antipattern
- Apply strangulation strategies to gradually improve code quality
- Prevent the introduction of new antipatterns in greenfield projects
Antipattern Categories
Antipatterns are organized into the following categories:
A. Structure and Architecture
- God Class
- God Method
- Inheritance Abuse
- Constructor Heavy
- High Cognitive Load Architecture
- Leaky Abstractions
- Hardcoded Infrastructure
- Infrastructure Leakage
B. State and Coupling
- Mutable Shared State
- Action at Distance
- Temporal Coupling
- Implicit Workflow Coupling
- Service Locator by Object State
- Hidden Side Effects
- Recursive Service Instantiation
- Environment Logic Scattered
C. Data Modeling (PHP)
- Primitive Obsession
- Array-Based Domain Modeling
- stdClass as Universal Model
- Anemic Domain Model
- Stringly Typed Architecture
- Boolean / Integer Flags
- Data Clumps
D. Security
- SQL Injection
- Security Anti-Patterns
- SSL Verification Disabled
E. Error Handling
- Silent Catch
- Exception Handling as Business Logic
- Fear-Driven Logging
F. Code and Maintainability
- Dead Code / Fossil Code
- Mixed Language Naming
- Magic Numbers
- DRY Violations
- Long Parameter List
G. Presentation and Communication
- Presentation Mixed with Domain
- Output Format Confusion
- Action-Based Routing (Numerical Actions)
- Server-Rendered HTML over AJAX
H. Database Design
- Magic Values as Type Discriminators
- Cross-Schema Queries Without Abstraction
- Duplicate Table Pairs
- Inconsistent Column Naming
- Redundant / Duplicated Columns
- JSON / Serialized Data in Columns
- N+1 Query Patterns in Loops
- SELECT * Anti-Pattern
- Missing Indexes Evidence
- UNION Without ALL
- Foreign Keys Disabled for Operations
- Soft Deletes Without Consistency
- Hardcoded Business Logic in SQL
- Polymorphic Discriminator Columns
- LIKE with Leading Wildcards
- Wide Table
- Repeating Groups (1NF Violation)
- DOUBLE for Money
- VARCHAR for Numeric Values
- Zero Date Default
- Obsolete Charset (latin1)
- Over-Indexing
- Missing Foreign Keys
- Trigger-Based Denormalization
- Catch-All Varchar Column
- Excessive Composite Primary Key
- Truncated Column Comments
I. Naming
- Mixed Language Naming (Spanglish)
- Inconsistent Prefix Conventions
- Ambiguous Abbreviations
- Inconsistent Verb Conventions
- Hungarian Notation Variants
- Schema-Level Naming Inconsistency
- Table Naming: Singular vs Plural
- Cryptic Variable Names
- Action Numbers Instead of Names
- Cryptic Column Abbreviations
- Numeric Suffix Columns
- Typo in Comments
J. Integrations and APIs
- Retry Storm
- No Idempotency in External Operations
- API Response Shape Coupling
- Vendor SDK Domain Leakage
K. Concurrency and Consistency
- Check-Then-Act Race Condition
- Transaction Script Without Transactions
- Distributed Transaction Illusion
L. Performance and Scalability
- Cache Aside Chaos
- Premature Micro-Optimization
- Batch Processing via Memory Explosion
M. Observability and Operations
- Log-and-Pray
- Monitoring Blind Spots
- Configuration by Database
N. Legacy Homemade Framework
- Homemade Framework Syndrome
- Copy-Paste Inheritance Framework
O. Deployment and Environments
- Snowflake Server
- Environment Drift
- Feature Flags by Commenting Code
P. Legacy Testing
- Integration Test as Unit Test
- Mock Everything Syndrome
- Golden Master Dependency
Q. Domain and Business
- Business Rules by Convention
- Zombie Features
R. Legacy Socio-Technical Patterns
- Fear-Driven Development
- Knowledge Silos
- Bus Factor One
- Tribal Knowledge Architecture
- Ticket-Driven Architecture
- Copy-Paste Onboarding
Methodology
Each antipattern will be addressed individually with a consistent structure that includes identification criteria, root causes, consequences and strangulation strategies.
The catalog will be progressively expanded with detailed analysis of each antipattern, including generic code examples that illustrate the problem and its resolution.
Next Steps
The antipatterns in this catalog will be addressed one by one in subsequent iterations. Each entry will include:
- Clear definition and identification criteria
- Generic code examples illustrating the antipattern
- Analysis of root causes and contributing factors
- Consequences and impact on the codebase
- Strangulation strategy with step-by-step guidance
- Refactored code examples showing the solution