EPISODE · Sep 18, 2025 · 19 MIN
Why Dirty Code Always Wins (Until It Doesn’t): Cross‑Cutting Concerns, Middleware, Decorators & How To Keep Business Logic Clean
from M365.FM - Modern work, security, and productivity with Microsoft 365 · host Mirko Peters - Founder of m365.fm, m365.show and m365con.net
Ever notice how the fastest way to ship is usually the messiest—logging scattered through controllers, validation copy‑pasted into handlers, authentication bolted on wherever it happens to work? It feels fast in the moment, but every shortcut adds weight until the codebase becomes something nobody wants to touch. In this episode, we look at why dirty code wins the short‑term race, how cross‑cutting concerns quietly smother your business logic, and how to use middleware, decorators and pipelines to keep shipping fast without turning your system into an unmaintainable tangle.WHY MESSY CODE FEELS LIKE THE FASTEST CODEUnder deadline pressure, “just make it work” feels rational: log right in the controller, paste the same validation into a few endpoints, wrap everything in try‑catch and move on. The feature ships, the business is happy, and the team gets praised for speed—so the pattern repeats. We unpack how this local optimization turns into global drag: duplicated checks, inconsistent behavior, and controller methods where actual business rules are buried under logging, validation and error‑handling noise. You’ll hear why this isn’t a skill problem but a structural one: without a place to put cross‑cutting concerns, they will always leak into your domain codeTHE RISE OF CROSS‑CUTTING CONCERNSLogging, authentication, validation, telemetry and audit trails don’t belong to any single feature, which is why they end up everywhere. We walk through how these cross‑cutting concerns creep in one “quick fix” at a time, multiplying across endpoints until every change means editing the same patterns in dozens of places. Over time, controllers stop reading like “create order” or “approve invoice” and instead look like “log, check, validate, catch, log again,” hiding intent and making onboarding brutally slow. Once you see this as a systemic concern—not a team discipline issue—you can start solving it with architecture instead of more code reviews.WHERE DESIGN PATTERNS ACTUALLY HELPPatterns like middleware, decorators, handlers and pipelines aren’t academic buzzwords—they’re how you pull cross‑cutting concerns out of your business code without losing speed. We discuss practical uses: logging decorators that wrap services without touching their methods, validation layers that sit before handlers, middleware pipelines that centralize authentication and error handling so controllers can stay thin. You’ll learn how to start small—wrapping one use case at a time—so you don’t trigger a massive rewrite, and how to use these patterns to keep “boring” domain logic clean even as requirements for observability and compliance grow.WHAT YOU’LL LEARNWhy messy, copy‑pasted code wins in the short term—and why it always slows you down later.How cross‑cutting concerns like logging, validation and authentication quietly take over controllers and handlers.How middleware, decorators and pipelines help you move those concerns out of business logic.How to keep shipping fast while still making your codebase more maintainable with each refactor.THE CORE INSIGHTThe core insight of this episode is that “dirty code vs clean code” is not a taste issue—it’s a system design issue. As long as you have nowhere to put cross‑cutting concerns, they will invade your business logic; once you introduce the right patterns, you can ship just as fast while making the next change cheaper instead of more expensive.WHO THIS EPISODE IS FORBackend and API developers who feel trapped between deadlines and code quality.Tech leads and architects trying to reduce boilerplate without slowing delivery.Teams in regulated or observable environments that need logging and audit trails without drowning in clutter.ABOUT THE AUTHOR / HOSTMirko Peters is a Microsoft 365 and backend architecture consultant and host of the M365.FM podcast, helping organizations treat their application code, infrastructure and observability as one integrated operating system instead of disconnected layers. He works with teams running on Microsoft 365, Azure and modern .NET stacks to design patterns, pipelines and governance that keep code shippable and maintainable—even when cross‑cutting demands like logging and compliance keep growing.Become a supporter of this podcast: https://www.spreaker.com/podcast/m365-fm-modern-work-security-and-productivity-with-microsoft-365--6704921/support.
What this episode covers
Ever notice how the fastest way to ship is usually the messiest—logging scattered through controllers, validation copy‑pasted into handlers, authentication bolted on wherever it happens to work? It feels fast in the moment, but every shortcut adds weight until the codebase becomes something nobody wants to touch. In this episode, we look at why dirty code wins the short‑term race, how cross‑cutting concerns quietly smother your business logic, and how to use middleware, decorators and pipelines to keep shipping fast without turning your system into an unmaintainable tangle.WHY MESSY CODE FEELS LIKE THE FASTEST CODEUnder deadline pressure, “just make it work” feels rational: log right in the controller, paste the same validation into a few endpoints, wrap everything in try‑catch and move on. The feature ships, the business is happy, and the team gets praised for speed—so the pattern repeats. We unpack how this local optimization turns into global drag: duplicated checks, inconsistent behavior, and controller methods where actual business rules are buried under logging, validation and error‑handling noise. You’ll hear why this isn’t a skill problem but a structural one: without a place to put cross‑cutting concerns, they will always leak into your domain codeTHE RISE OF CROSS‑CUTTING CONCERNSLogging, authentication, validation, telemetry and audit trails don’t belong to any single feature, which is why they end up everywhere. We walk through how these cross‑cutting concerns creep in one “quick fix” at a time, multiplying across endpoints until every change means editing the same patterns in dozens of places. Over time, controllers stop reading like “create order” or “approve invoice” and instead look like “log, check, validate, catch, log again,” hiding intent and making onboarding brutally slow. Once you see this as a systemic concern—not a team discipline issue—you can start solving it with architecture instead of more code reviews.WHERE DESIGN PATTERNS ACTUALLY HELPPatterns like middleware, decorators, handlers and pipelines aren’t academic buzzwords—they’re how you pull cross‑cutting concerns out of your business code without losing speed. We discuss practical uses: logging decorators that wrap services without touching their methods, validation layers that sit before handlers, middleware pipelines that centralize authentication and error handling so controllers can stay thin. You’ll learn how to start small—wrapping one use case at a time—so you don’t trigger a massive rewrite, and how to use these patterns to keep “boring” domain logic clean even as requirements for observability and compliance grow.WHAT YOU’LL LEARNWhy messy, copy‑pasted code wins in the short term—and why it always slows you down later.How cross‑cutting concerns like logging, validation and authentication quietly take over controllers and handlers.How middleware, decorators and pipelines help you move those concerns out of business logic.<a...
NOW PLAYING
Why Dirty Code Always Wins (Until It Doesn’t): Cross‑Cutting Concerns, Middleware, Decorators & How To Keep Business Logic Clean
No transcript for this episode yet
Similar Episodes
Mar 26, 2026 ·1m
Mar 19, 2026 ·34m
Feb 18, 2026 ·11m
Feb 11, 2026 ·45m