Tools and practices to help you deal with legacy code - Dennis Doomen - NDC Porto 2023

Learn effective strategies to tame and improve your legacy codebase, including techniques for removing dead code, writing unit tests, and using code analysis tools to increase maintainability and reduce technical debt.

Key takeaways
  • Tools and practices to help deal with legacy code:
    • Remove dead code
    • Apply dependency inversion principle
    • Write unit tests
    • Use code analysis tools (e.g. Roslyn Analyzer)
    • Use a build script (e.g. Pulumi) to automate tasks
    • Use type dependency diagrams to understand code dependencies
    • Encapsulate logic and data
    • Use logging guidelines and consider using logging frameworks
    • Delete commented-out code
    • Improve code organization and structure
    • Reduce coupling between components
    • Use pattern matching and switch expressions
    • Use type-safe dependencies
    • Use code coverage analysis tools (e.g. Coverlet)
    • Use a version control system (e.g. Git) with branching strategies (e.g. GitFlow)
  • Additional ideas:
    • Use a safety net to prevent mistakes
    • Document code and architecture
    • Apply design patterns and principles (e.g. Single Responsibility Principle)
    • Improve code readability and maintainability
    • Reduce technical debt
    • Use automated tests and test-driven development (TDD)
    • Use code refactoring tools and techniques
    • Improve code organization and structure
    • Consider using open-source projects (e.g. Pulumi) and maintainable libraries
    • Use design patterns and principles (e.g. Repository Pattern) to improve architecture
  • Quotes and insights:
    • “We all love greenfield stuff. But yeah, I happen to do that.” - Dennis Doomen
    • “Code is not just lines of code, it’s a living system.” - Dennis Doomen