Skip to content

Instantly share code, notes, and snippets.

@MangaD
Created April 19, 2025 23:38
Show Gist options
  • Save MangaD/567a86f954b4b0ed46b9d1e95dbed798 to your computer and use it in GitHub Desktop.
Save MangaD/567a86f954b4b0ed46b9d1e95dbed798 to your computer and use it in GitHub Desktop.
Anti-patterns in software engineering

Anti-patterns in software engineering

CC0

Disclaimer: ChatGPT generated document.

Anti-patterns in software engineering are common responses to recurring problems that may seem like good ideas at the time but end up being counterproductive, harmful, or unsustainable in the long term.

They are like the β€œbad habits” of code, design, or process β€” well-intentioned, sometimes popular, but ultimately flawed solutions that developers (especially under pressure) fall into.


🧩 Definition

πŸ” An anti-pattern is a design or implementation approach that is ineffective or harmful, especially when better alternatives exist.

They are the opposite of design patterns, which are proven best practices for solving common software problems.


🚨 Why Anti-Patterns Happen

  • Lack of experience or mentorship
  • Tight deadlines and shortcuts
  • Misunderstanding of architecture principles
  • Copy-pasting code without understanding
  • Overengineering or underengineering
  • Following trends without adapting to context

πŸ’» Common Types of Anti-Patterns in Software Engineering

🧱 1. Spaghetti Code

  • Code with no structure, tangled logic, and poor readability.
  • Symptoms: hard to maintain, test, or debug.

πŸ‘Ž Happens when quick fixes are prioritized over modularity.


πŸ—οΈ 2. God Object / God Class

  • One class does too much β€” manages everything from logic to data to UI.
  • Violates Single Responsibility Principle.

πŸ‘Ž Leads to tightly coupled, untestable code.


πŸ” 3. Copy-Paste Programming

  • Repeating the same code in multiple places instead of using functions or modules.

πŸ‘Ž Hard to maintain β€” a bug in one place must be fixed in many places.


πŸ”§ 4. Reinventing the Wheel

  • Writing custom implementations for things already well-solved (e.g., writing your own sort algorithm).

πŸ‘Ž Wastes time, introduces bugs, and ignores reliable libraries.


πŸ“¦ 5. Premature Optimization

  • Trying to optimize before the real bottlenecks are known.

πŸ‘Ž Adds complexity without proven benefit; often violates YAGNI ("You Aren’t Gonna Need It").


🏰 6. Overengineering

  • Designing systems with excessive abstraction, configuration, or generalization β€œjust in case.”

πŸ‘Ž Makes code harder to understand and slower to deliver.


πŸ—ΊοΈ 7. Lava Flow

  • Legacy or experimental code that never gets cleaned up, but remains in production.

πŸ‘Ž Creates fragile systems and confuses new developers.


πŸ“› 8. Magic Numbers / Strings

  • Hard-coded values scattered throughout code.

πŸ‘Ž Makes code unclear and harder to refactor. Use named constants or enums.


πŸ’₯ 9. Shotgun Surgery

  • A small change requires touching many unrelated files/modules.

πŸ‘Ž Sign of poor modularity or tight coupling.


πŸ€– 10. Cargo Cult Programming

  • Using patterns, tools, or libraries without understanding why β€” just because β€œothers do it.”

πŸ‘Ž Often leads to bloated or poorly adapted solutions.


πŸ› οΈ Process & Team Anti-Patterns

❌ Big Bang Integration

Waiting until the end to integrate modules, leading to chaos.

❌ Death March

Unrealistic schedules lead to burnout and bad code.

❌ Design by Committee

Too many decision-makers with conflicting ideas = bloated, unfocused system.

❌ Micromanagement

Stifles creativity, autonomy, and slows progress.


🧠 How to Avoid Anti-Patterns

  • βœ… Embrace design principles (SOLID, DRY, KISS, YAGNI)
  • βœ… Prioritize code reviews and mentorship
  • βœ… Use unit tests and modular design
  • βœ… Refactor regularly
  • βœ… Don’t guess β€” profile before optimizing
  • βœ… Favor clarity and simplicity over cleverness

🧾 Summary

Anti-Pattern What It Is Better Approach
Spaghetti Code Messy, tangled logic Modular, clean design
God Object One class does too much Follow Single Responsibility
Copy-Paste Duplicated code Use functions, DRY principle
Premature Optimization Early, unjustified tuning Profile first, optimize later
Overengineering Too much abstraction or flexibility Keep it simple, build as needed
Lava Flow Uncleaned legacy code Refactor, document, delete dead code

Would you like a cheat sheet of common anti-patterns in C++, OOP, or Agile processes specifically?


Further reading: https://en.wikipedia.org/wiki/Anti-pattern

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment