Practical tips for keeping your C# code base clean
dennisdoomen
4 views
43 slides
Oct 31, 2025
Slide 1 of 45
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
About This Presentation
As soon as a codebase grows to a certain point, almost every team struggles to keep that codebase under control. Coding conventions are no longer followed, code reviews become superficial, refactoring doesn't happen as often as it should, and developers lose sight of the original architecture. F...
As soon as a codebase grows to a certain point, almost every team struggles to keep that codebase under control. Coding conventions are no longer followed, code reviews become superficial, refactoring doesn't happen as often as it should, and developers lose sight of the original architecture. Fortunately our toolbox contains quite some tools to help you with this, and next to that there are plenty of practices and learnings to help structure your code in more functional manner.
Size: 44.59 MB
Language: en
Added: Oct 31, 2025
Slides: 43 pages
Slide Content
40 practical tips for keeping your C# code base healthy Dennis Doomen @ddoomen | Principal Consultant | Microsoft MVP
About Me Coding Architect .NET/C# Bit of TS/JS/React/Vue 29 years of “pro” experience Author of FluentAssertions , Pathy, PackageGuard , Reflectify , .NET Library Starter Kit www.dennisdoomen.com BlueSky, Twitter, Mastodon, LinkedIn
Establish clean source control guidelines
Establish (HTTP) exception and logging guidelines
Merge microservices that don't need independent scaling µService µService µService µService µService µService µService µService µService µService µService µService µService µService µService µService Modular Monolith µService µService µService µService Service Service Service Service Service Service
Align projects with the deployment or reusability scope
Make the folder structure explain the architecture
Keep concrete classes internal by only exposing an interface
Use . editorconfig and Prettier to automatically format code
Use .NET analyzers and ESLint to get early code quality feedback
Use JetBrain’s Cleanup Profiles for auto clean-up
Use directory.build.props and . editorconfigs to gradually enforce standards
Document the purpose of code, not how it does that
Replace lots of dependencies with a single reversed interface MyController ISomeRepository IExternalService IOtherModule Specific interface Adapter ISomeRepository IExternalService IOtherModule MyController
Get rid of separate validators and query/handlers patterns Finance Controller Some Request Handler Request validator IValidate < RequestValidator > IHandle < SomeRequestQuery >
Don’t forget the OO principles
Replace List<T> or Dictionary<T> with a custom collection class Order OrderLine List< OrderLine > Order OrderLine OrderLineCollection
Don't introduce interfaces if you don't need them
Move container registrations into the functional folder
Split bloated interfaces Finance Service IFinanceService Finance Service IProvideVatRates ICalculateIncomeTaxes ITransactionHistory
Replace single-method interfaces with delegates
Ensure every PR makes the code a little bit better
Use // REFACTOR and // SMELL comments https://www.infoq.com/articles/natural-course-refactoring/
Keep your licenses in check
Learn to use AI assistants and agents
Spell check your code
Replace Bicep & Terraform with Pulumi
Switch to GitHub and Dependabot or adopt Renovate
Use Nuke to evolve your build script over time
Learn from others
Find me at bluesky : @ddoomen.bsky.social mastodon : @ddoomen.mastodon.social twitter : ddoomen email : [email protected]