ycliper

Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
Скачать

Replace Switch Statements with the Strategy Pattern in C#

Автор: Milan Jovanović

Загружено: 2026-03-13

Просмотров: 12307

Описание: Join the .NET Architects Club: https://www.skool.com/mj-tech-communi...
Get the 2026 .NET Developer roadmap here → https://the-dotnet-weekly.ck.page/202...
Want to master Clean Architecture? Go here: https://bit.ly/3PupkOJ
Want to master Modular Monoliths? Go here: https://bit.ly/3SXlzSt

In this video, I walk through how to refactor a complex piece of C# code using the Strategy Pattern.

The starting point is an OrderProcessor with a large switch statement that handles shipping cost calculations for multiple providers. That approach works at first, but it quickly becomes harder to maintain, harder to extend, and harder to test as the logic grows.

I show how to extract that behavior into individual strategy classes behind a shared abstraction, register them with dependency injection, and resolve them through IEnumerable[IShippingStrategy] into a dictionary for fast lookup.

We also cover why this refactor is useful in practice:
Smaller, more focused classes
Fewer unnecessary dependencies in your core workflow
Simpler testing of individual behaviors
Easier extension without modifying existing code
Better alignment with the Open/Closed Principle

I also show how easy it becomes to add a new shipping provider once the pattern is in place. Instead of changing the OrderProcessor, you add a new strategy implementation and register it with DI.

If you’ve ever had a class full of if statements or a big switch that keeps growing over time, this refactor will feel very familiar.

Check out my courses:
https://www.milanjovanovic.tech/courses

Read my Blog here:
https://www.milanjovanovic.tech/blog

Join my weekly .NET newsletter:
https://www.milanjovanovic.tech

Chapters

Не удается загрузить Youtube-плеер. Проверьте блокировку Youtube в вашей сети.
Повторяем попытку...
Replace Switch Statements with the Strategy Pattern in C#

Поделиться в:

Доступные форматы для скачивания:

Скачать видео

  • Информация по загрузке:

Скачать аудио

Похожие видео

Stop Making This EF Core Transaction Mistake

Stop Making This EF Core Transaction Mistake

C# is cool again and you can't avoid it anymore...

C# is cool again and you can't avoid it anymore...

How to protect an MCP Server with an API Key [AI in C#]

How to protect an MCP Server with an API Key [AI in C#]

What Every .NET Developer Actually Needs to Know in 2026

What Every .NET Developer Actually Needs to Know in 2026

What is Span in C# and why you should be using it

What is Span in C# and why you should be using it

Принятие неудачи

Принятие неудачи

"Clean" Code, Horrible Performance

cybersecurity is about to get weird

cybersecurity is about to get weird

M5 Pro просто ПОТРЯСАЮЩЕ превосходит M4 Pro — БЕЗУМИЕ!

M5 Pro просто ПОТРЯСАЮЩЕ превосходит M4 Pro — БЕЗУМИЕ!

Чистая архитектура с ASP.NET Core 10

Чистая архитектура с ASP.NET Core 10

Async Await Just Got A Massive Improvement in .NET

Async Await Just Got A Massive Improvement in .NET

The Strange Math That Predicts (Almost) Anything

The Strange Math That Predicts (Almost) Anything

How to Secure .NET 10 APIs with Keycloak and OAuth 2.0

How to Secure .NET 10 APIs with Keycloak and OAuth 2.0

“Just Use Exceptions” Is Bad Advice in .NET

“Just Use Exceptions” Is Bad Advice in .NET

My Complete Tech Stack for Side Projects in 2026

My Complete Tech Stack for Side Projects in 2026

Is RAG Still Needed? Choosing the Best Approach for LLMs

Is RAG Still Needed? Choosing the Best Approach for LLMs

This Paradox Splits Smart People 50/50

This Paradox Splits Smart People 50/50

«Матрица» приближается

«Матрица» приближается

MS NOW EXCLUSIVE with Iranian Foreign Minister Abbas Araghchi

MS NOW EXCLUSIVE with Iranian Foreign Minister Abbas Araghchi

Why can't the U.S. just take over the Strait of Hormuz? | About That

Why can't the U.S. just take over the Strait of Hormuz? | About That

© 2025 ycliper. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]