SlideShare a Scribd company logo
tools, practices and principles
My recipe for dealing with legacy code
Dennis Doomen
@ddoomen | The Continuous Improver | Aviva Solutions
About Me
Hands-on architect in the .NET space with 27 years of experience on
an everlasting quest for knowledge to build the right software the right
way at the right time
@ddoomen | The Continuous Improver | Aviva Solutions
Tools and practices to help you deal with legacy code
Win a 1-year license for
Jetbrains Rider
twitter: ddoomen
mastodon: @ddoomen.mastodon.social
bluesky: @ddoomen.bsky.social
How I work
@ddoomen | The Continuous Improver | Aviva Solutions
My typical improvement
flow
Understand the
production
environment
Understand the
code base
Find dead and
unused code
Build a safety
net
Improve
deployability
Improve code
quality
Improve code
design
Improve
architecture
Understand the production environment
@ddoomen | The Continuous Improver | Aviva Solutions
Get .EXE, .DLLs, logs and
config files from production
environment
Compare .NET binaries with source control
Analyze log files and crash
reports
Get it to run locally
Understanding the code
@ddoomen | The Continuous Improver | Aviva Solutions
Inspect the project
dependencies, folder names
and namespaces
Use Type Dependencies Diagram in R#
Use NDepend
Build C4 Diagrams
Draw your own class diagrams
Use your IDE
Let AI tooling explain
the code
Track all notes in a single place
Find and remove dead code
@ddoomen | The Continuous Improver | Aviva Solutions
Reduce code visibility
Remove unused code
Remove commented-out code
Build a safety net
@ddoomen | The Continuous Improver | Aviva Solutions
Add code coverage
Characteristics Test Suite
Add characteristics tests
Application
Legacy Code Base
Production Backup
Use Test Containers
Characteristics Test Suite
Application
Legacy Code Base
Linux Test Container
SQL Server
Add a couple of UI tests
Browser Tests
Application
Legacy Code Base
Production Backup
Legacy Web UI
Improve deployability
@ddoomen | The Continuous Improver | Aviva Solutions
Add build “script” that can run
locally
Adopt versioning strategy
and branch naming conventions
https://quangnguyennd.medium.com/git-flow-vs-github-flow-620c922b2cbd
Add automatic
versioning
Adopt logging and exception
strategy
Automate deployments
(e.g. Pulumi, Ansible, etc)
Improve code
@ddoomen | The Continuous Improver | Aviva Solutions
Treat all warnings as errors
and fix them
Add .editorconfig to allow
auto-formatting
(for VS, VS Code and Rider)
Add Roslyn Analyzers
• XML comment formatting
• LINQ performance improvements
• Nested conditional statements
• Long methods
• Single type per file
• Correct exception types
• Proper async supports
Enable C# Nullable Types
Move to .NET 6+ and bump C#
version
• file-scoped namespaces
• global usings
• target-type new
• switch expression
• string interpolation
• raw strings
• pattern matching
• or operator
Using PolySharp to enable newer C#
features on older frameworks
Directory.build.props
Improve naming
whenever you can
Encapsulate access to
properties through
methods
Improve design
@ddoomen | The Continuous Improver | Aviva Solutions
Organize by functionalities / capabilities
Apply DRY within those “boundaries”
Duplicated
Service 1
Duplicated
Service 1
Duplicated
Service 2
Duplicated
Service 2
Duplicated
Service 1
Centralized
Service 3
Extension
Methods
Extension
Methods
Extension
Methods
Extension
Methods
Helpers Helpers Helpers Helpers
Service Service
Service Service
Service
Centralized
Service
Align your test scope with those “boundaries”
Avoid technical folders and organize code by
functionalities / capabilities
Functional
Folders
“Unit” of (integration)
testing
DRY within boundaries
Can be used to
clarify “public”
parts
Only unit tested
for specific
reasons
Role-based
interface name
Treat adjacent folders as
separate boundaries
Refactor towards Design
Patterns
Adopt an architecture
style that embraces the
DIP
Order Processing
IStoreOrders<T>
+ Query<T>();
+ Add<T>();
+ Delete<T>();
NHibernate
Repository
Order Processing
IStoreOrders
+ GetIncompleteOrders(minValue);
+ StoreOrder();
+ CompleteOrder();
OrderRepository
VS
Main Package
Application
Bunch of blocks that
can be used directly
Uses composition
over inheritance
Convenience
blocks that don’t
hide the magic
Shared Package
Contract
Contract
Only depend on
more abstract
packages…
Stable Package
…or depend on more
stable packages
Auxiliary Package
Blocks that are not
used together do not
belong together
Optional
Dependency
Dependency
Package
Consumers should
not be faced with
optional
dependencies
No cyclic
dependencies
Apply principles of successful package
management
Improve architecture
@ddoomen | The Continuous Improver | Aviva Solutions
Use your learnings to visualize the target architecture
Consider
Onion
Architecture
Domain Model
-or-
Hexagonal
Architecture
(a.k.a. Ports
& Adapters)
Domain
Application
Primary Port
Primary Port
Secondary
Port
Secondary
Port
Web
Adapter
API
Adapter
Database
Adapter
Adapter
Dependencies Dependencies
-or-
Clean
Architecture
Entities
Q&A
Join me at 14:30 in room 7
Meet me near room 11
Also find me at
twitter: ddoomen
mastodon: @ddoomen.mastodon.social
bluesky: @ddoomen.bsky.social
email: dennis.doomen@avivasolutions.nl
slack: fluentassertions.slack.com

More Related Content

PPTX
My Laws of Test Driven Development (2023)
PPTX
What you can learn from an open-source project with 250 million downloads
PPTX
A lab around the principles and practices for writing maintainable code (2019)
PPTX
How to Practice TDD Without Shooting Yourself in the Foot
PPTX
Getting a grip on your code dependencies
PPTX
Getting a grip on your code dependencies (2023-10)
PPTX
How To Practice TDD Without Shooting Yourself In The Foot
PPTX
How to practice TDD without shooting yourself in the foot
My Laws of Test Driven Development (2023)
What you can learn from an open-source project with 250 million downloads
A lab around the principles and practices for writing maintainable code (2019)
How to Practice TDD Without Shooting Yourself in the Foot
Getting a grip on your code dependencies
Getting a grip on your code dependencies (2023-10)
How To Practice TDD Without Shooting Yourself In The Foot
How to practice TDD without shooting yourself in the foot

Similar to Tools and practices to help you deal with legacy code (20)

PPT
Parasoft .TEST, Write better C# Code Using Data Flow Analysis
PPTX
Improving Software Development Across the Lifecycle with Microsoft Visual Stu...
 
PPTX
A lab around the principles and practices for writing maintainable code
PPTX
Using Boundary-Driven Development to beat code complexity
PPT
The Magic Of Application Lifecycle Management In Vs Public
PPTX
Software Reengineering
PPTX
A modern architecturereview–usingcodereviewtools-ver-3.5
 
PPTX
A Lap Around Visual Studio 2010
PDF
Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham
PPTX
Neotys PAC - Stijn Schepers
PPTX
Code in the Cloud - December 8th 2014
PPTX
PPTX
Code in the Cloud - Ghent - 20 February 2015
PPTX
Improving the Design of Existing Software
PPTX
Typical Developer Day
PPT
Visual Studio Team System 2010
 
PPT
Smells @muc_rubyshift 06/2013
PDF
Back to the basics principles for constructing quality software
PPTX
ALM@Work - Typical developer day
PDF
Keeping code clean
Parasoft .TEST, Write better C# Code Using Data Flow Analysis
Improving Software Development Across the Lifecycle with Microsoft Visual Stu...
 
A lab around the principles and practices for writing maintainable code
Using Boundary-Driven Development to beat code complexity
The Magic Of Application Lifecycle Management In Vs Public
Software Reengineering
A modern architecturereview–usingcodereviewtools-ver-3.5
 
A Lap Around Visual Studio 2010
Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham
Neotys PAC - Stijn Schepers
Code in the Cloud - December 8th 2014
Code in the Cloud - Ghent - 20 February 2015
Improving the Design of Existing Software
Typical Developer Day
Visual Studio Team System 2010
 
Smells @muc_rubyshift 06/2013
Back to the basics principles for constructing quality software
ALM@Work - Typical developer day
Keeping code clean
Ad

More from Dennis Doomen (20)

PDF
15 Years of Insights from a TDD Practitioner (NDC Oslo)
PPTX
Design patterns for Event Sourcing in .NET
PPTX
Automate Infrastructure with Pulumi and C#
PPTX
What is the right unit in unit testing (UpdateConf 2022)
PPTX
Slow Event Sourcing (re)projections - Just make them faster!
PPTX
50 things software teams should not do.pptx
PPTX
What is the right "unit" in unit testing and why it is not a class?
PPTX
Decomposing the Monolith using modern-day .NET and a touch of microservices
PPTX
Event Sourcing from the Trenches (DDD Europe 2020)
PPTX
Practical introduction to DDD, CQRS and Event Sourcing
PPTX
How to practice TDD without shooting yourself in the foot
PPTX
Decomposing the Monolith (Riga Dev Days 2019)
PPTX
Lessons learned from two decades of professional software development
PPTX
The Good, The Bad and The Ugly of Event Sourcing
PPTX
Event Sourcing from the Trenches (with examples from .NET)
PPTX
Decomposing the monolith into embeddable microservices using OWIN, WebHooks, ...
PPTX
Strengths and weaknesses of dependency injection
PPTX
Build Libraries That People Love To use
PPTX
Decomposing the Monolith using Microservices that don't give you pain
PPTX
Build Libraries, Not Frameworks
15 Years of Insights from a TDD Practitioner (NDC Oslo)
Design patterns for Event Sourcing in .NET
Automate Infrastructure with Pulumi and C#
What is the right unit in unit testing (UpdateConf 2022)
Slow Event Sourcing (re)projections - Just make them faster!
50 things software teams should not do.pptx
What is the right "unit" in unit testing and why it is not a class?
Decomposing the Monolith using modern-day .NET and a touch of microservices
Event Sourcing from the Trenches (DDD Europe 2020)
Practical introduction to DDD, CQRS and Event Sourcing
How to practice TDD without shooting yourself in the foot
Decomposing the Monolith (Riga Dev Days 2019)
Lessons learned from two decades of professional software development
The Good, The Bad and The Ugly of Event Sourcing
Event Sourcing from the Trenches (with examples from .NET)
Decomposing the monolith into embeddable microservices using OWIN, WebHooks, ...
Strengths and weaknesses of dependency injection
Build Libraries That People Love To use
Decomposing the Monolith using Microservices that don't give you pain
Build Libraries, Not Frameworks
Ad

Recently uploaded (20)

PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Encapsulation theory and applications.pdf
PDF
KodekX | Application Modernization Development
 
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Big Data Technologies - Introduction.pptx
PPT
Teaching material agriculture food technology
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
DOCX
The AUB Centre for AI in Media Proposal.docx
 
PPTX
Cloud computing and distributed systems.
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Spectroscopy.pptx food analysis technology
Per capita expenditure prediction using model stacking based on satellite ima...
Encapsulation theory and applications.pdf
KodekX | Application Modernization Development
 
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Chapter 3 Spatial Domain Image Processing.pdf
Big Data Technologies - Introduction.pptx
Teaching material agriculture food technology
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Dropbox Q2 2025 Financial Results & Investor Presentation
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
MYSQL Presentation for SQL database connectivity
Reach Out and Touch Someone: Haptics and Empathic Computing
Programs and apps: productivity, graphics, security and other tools
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Understanding_Digital_Forensics_Presentation.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
The AUB Centre for AI in Media Proposal.docx
 
Cloud computing and distributed systems.
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Spectroscopy.pptx food analysis technology

Tools and practices to help you deal with legacy code