Writing and keeping .NET code maintainable: clean code, refactoring techniques, code smells, static analysis with Roslyn analysers and SonarQube, and the engineering practices (reviews, ADRs, tech debt, definition of done) that keep a codebase healthy.
-
How do you name things well in C#? What makes a name intention-revealing, which .NET naming conventions matter, and why should you avoid abbreviations and type names in identifiers?
Covers intention-revealing names, the .NET naming conventions (PascalCase, camelCase, I-prefix, Async suffix), and avoiding abbreviations, Hungarian notation and type names in identifiers.
Junior
Theory
Clean Code
Β· π 2 follow-ups
-
What does "clean code" actually mean in practice? How do readability and maintainability differ, and how would you tell whether a piece of C# code is clean?
Defines clean code in practical terms, separates readability (understanding code now) from maintainability (changing it safely later), and gives observable tests for clean C#.
Beginner
Theory
Clean Code
Β· π 3 follow-ups
-
People say methods and classes should be small. How small is small? When should you split a method or class, and when does splitting actually make the code harder to follow?
Explains the real criteria for splitting methods and classes (one level of abstraction, one reason to change, cohesion), and the failure mode of over-splitting into tiny, scattered indirection.
Intermediate
Theory
Clean Code
Β· π 2 follow-ups Β· π 1 real-world
-
What is a hidden side effect? Explain command-query separation, pure functions and immutability, and show how you would remove a side effect hiding inside a C# method.
Covers what hidden side effects are and why they cause bugs, command-query separation (CQS), pure functions, immutability with records and init-only properties, and pushing side effects to the edges of the code.
Mid-Level
Theory
Clean Code
Β· π 2 follow-ups Β· π 1 real-world
-
You find the same discount calculation copy-pasted, with small differences, in three order handlers. Walk me through deciding whether to extract it. How do you tell real duplication from coincidental similarity, and what do you do if an earlier extraction turned out to be the wrong abstraction?
Applies duplication judgment to real code: knowledge versus coincidental duplication, the rule of three, extracting safely under tests, and undoing a wrong abstraction by inlining it back.
Mid-Level
Theory
Clean Code
Β· π 2 follow-ups Β· π 1 real-world
-
Code review: an order service has a single 300-line PlaceOrder method that validates input, calculates prices and GST, writes to the database, charges the card and sends a confirmation email. How would you review it, and how would you make it readable step by step without breaking anything?
A senior code review of a 300-line order method: ranking findings by severity (double charges, partial writes, swallowed errors, hidden time), writing kind and specific review comments, and a safe step-by-step plan to make it readable.
Senior
CodeReview
Clean Code
Β· π 3 follow-ups Β· π 1 real-world
-
What is refactoring, and what isn't it? Why do you need tests before you start, and how do you keep a refactoring safe while you work?
Defines refactoring as behaviour-preserving structural change, separates it from rewrites, fixes and features, and explains why tests (or characterisation tests) and small committed steps make it safe.
Junior
Theory
Refactoring
Β· π 2 follow-ups
-
Show me extract method and extract class on a real C# example. How do the IDE refactorings in Visual Studio and Rider do it safely, and what can still go wrong?
Walks through Extract Method and Extract Class on an order service, how Roslyn-based IDE refactorings handle parameters, return values and references, and the cases (out parameters, async, reflection, captured state) where they still change behaviour.
Intermediate
Coding
Refactoring
Β· π 2 follow-ups Β· π 1 real-world
-
A CreateInvoice method takes nine parameters and its body is nested five levels deep in if statements. How would you refactor it with introduce parameter object, guard clauses and pattern matching, and what traps should you avoid?
Refactors a long-parameter, deeply nested invoice method using Introduce Parameter Object (a record), guard clauses and switch expressions, and covers the traps: changed validation order, bag-of-everything parameter objects, boolean flags and non-exhaustive switches.
Intermediate
Coding
Refactoring
Β· π 2 follow-ups Β· π 1 real-world
-
An Invoice class switches on its Kind in five different methods. How would you replace the type code with polymorphism, when is a dictionary of strategies or a single switch expression the better choice, and when should you leave the conditional alone?
Applies Replace Conditional with Polymorphism to an invoice type code repeated across methods, compares subclasses, a dictionary of strategies and switch expressions, and covers the expression problem, EF Core inheritance mapping and when to keep the switch.
Mid-Level
Coding
Refactoring
Β· π 3 follow-ups Β· π 1 real-world
-
How do you find and remove dead code in a large .NET codebase with confidence? Explain what analysers, code coverage, production telemetry and feature flags each tell you, and how you delete safely.
Covers finding dead code with compiler and IDE analysers (IDE0051, IDE0052, IDE0060), solution-wide analysis, coverage and production telemetry, removing stale feature flags, and a safe deletion process with tombstones and small reversible PRs.
Mid-Level
Theory
Refactoring
Β· π 3 follow-ups Β· π 1 real-world
-
Show me in code how you break the dependencies that stop a legacy OrderService from being unit tested: DateTime.Now, a static helper, new SqlConnection inside a method and a sealed third-party client. Which seams and techniques would you use, and how does TimeProvider help?
Demonstrates dependency-breaking techniques on a legacy order service: TimeProvider and FakeTimeProvider for the clock, wrapping statics behind an instance, extracting a data-access dependency, adapting a sealed SDK client, and choosing between object seams, constructor parameterisation and integration tests.
Senior
Coding
Refactoring
Β· π 3 follow-ups Β· π 1 real-world
-
You need to refactor the payment allocation module that every invoice flows through, while two other teams keep shipping features in it. Walk me through how you would do it: the plan, the safety nets, how you keep PRs small and how you know it's safe to switch over.
A real-world plan for refactoring a critical payment allocation module during ongoing feature work: characterisation and golden-master tests, branch by abstraction, small trunk-based PRs, shadow (parallel) runs comparing old and new results, flag-controlled cut-over and coordination with other teams.
Senior
RealWorldScenario
Refactoring
Β· π 3 follow-ups Β· π 1 real-world
-
How would you find the parts of a large codebase where code smells actually cost the team the most?
Junior
Theory
Code Smells
-
What is a code smell? How is it different from a bug, and which smells do you most often find in real .NET codebases?
Defines a code smell versus a bug, groups the classic smells (bloaters, couplers, change preventers, object-orientation abusers, dispensables) and names the ones most common in .NET business code.
Junior
Theory
Code Smells
Β· π 2 follow-ups
-
What are the god class and long method smells? Why do they keep appearing, especially in .NET services and handlers, how do you recognise them, and how would you break one up safely?
Covers the god class and long method smells: their causes in .NET (fat services, handlers and controllers), how to recognise them with metrics and reading, and how to break them up with extract method, extract class and splitting by responsibility.
Intermediate
Theory
Code Smells
Β· π 3 follow-ups Β· π 1 real-world
-
What is primitive obsession? Show how you would fix it in C# with strongly typed IDs, value objects and records, and explain the costs, including EF Core mapping, serialisation and validation.
Explains primitive obsession, the bugs it allows (swapped IDs, unvalidated strings, currency-less money), and how to fix it with readonly record struct IDs, validated value objects and records, including EF Core value converters, JSON serialisation and where to validate.
Mid-Level
Coding
Code Smells
Β· π 2 follow-ups Β· π 1 real-world
-
What are feature envy and inappropriate intimacy? How do you spot them in a C# codebase, and how do you fix them by moving behaviour to the data, without ending up with entities that depend on infrastructure?
Covers the feature envy and inappropriate intimacy coupler smells, how they show up in .NET (service methods reading another object's fields, classes reaching into each other's internals, message chains), and how to fix them with move method, tell-don't-ask and encapsulation while keeping entities free of infrastructure.
Mid-Level
Theory
Code Smells
Β· π 2 follow-ups Β· π 1 real-world
-
What are shotgun surgery and tight coupling? How would you find them using your version control history (change coupling) as well as the code, and how do you fix them in a .NET solution?
Explains shotgun surgery, divergent change and tight coupling, how to detect them from git history (files that change together, temporal coupling) and from code (dependency graphs, CA1506), and how to fix them by co-locating behaviour, vertical slices and stable abstractions in .NET.
Mid-Level
Theory
Code Smells
Β· π 3 follow-ups Β· π 1 real-world
-
Code review: you're reviewing a 250-line CustomerAccountService that handles sign-up, loyalty points, invoice emails and CSV export. Name every code smell you find, rank them, and tell me which you would ask to be fixed in this PR and which you would log as technical debt.
A code review exercise that names the smells in a realistic .NET service (god class, long method, primitive obsession, feature envy, duplicated code, hidden side effects, dead code), ranks them by severity, and separates must-fix-now comments from items logged as technical debt.
Senior
CodeReview
Code Smells
Β· π 3 follow-ups Β· π 1 real-world