Magnus Mårtensson
Microsoft Regional Director, Azure MVP, CEO Loftysoft
Avirag Jain
Director & CTO R Systems
Mahesh Chand
Founder C# Corner, CEO Mindcracker
Chris Gali
CEO & Co-Founder Graphite
Subinder Khurana
Chief Architect StoryProcess, Founder NASSCOM DeepTech Club
Bryan Rishforth
Investor, Chairman Graphite
Bryn Everson
Director Biz Dev Graphite
Raj Tiwari
Digital Transformation Leader, Futurist and Visionary
Joseph Guadagno
Microsoft MVP, Lead Quicken Loans
Nikita Sachdev
Entrepreneur, Blockchain Enthusiast & Advisor, Social Media Influencer
Doug Wagner
COO & Founder Adapt Technical Group
Ritesh Modi
Architect, Senior Evangelist, Cloud Architect
Crystal Wenrick
Director Communications Mindcracker
Allen O’Neill
Microsoft MVP, Consulting Engineer/Architect
Praveen Kumar
CEO MCN Solutions
Chris Love
Founder Love2Dev, Microsoft MVP, Author
Sanjay Vyas
Microsoft Regional Director, Microsoft MVP, Founder & CEO SkillLabs Technologies
Veena Sarda
Deep Learning Consultant, Author
Sekhar Srinivasan
C# Corner MVP, Microsoft Certified Trainer, Pluralsight Author
Lalit Bansal
Founder & CEO - EIY SYS
Navdeep Garg
CEO Revinfotech
Prakash Tripathi
Tech Manager/Leader, Microsoft MVP, Blogger
Bhavna Jain
Breakthrough Consultant
Naveen Sharma
Enterprise Architect, Leadership Coach, Author
Vidya Vrat Agarwal
Principal Architect, Microsoft MVP, Author
Sheetal Agarwal
Founder Clownselors, Medical Clown, Trainer
Abhishek Kant
Founder GTM Catalyst
Vishnu Saran
Founder & CEO VoiceQube
Sandeep Soni
Founder & CEO Deccansoft, Microsoft Certified Trainer
Parveen Malik
AVP InfoSec & Vulnerability Management, Information Security Expert
Nitin Pandit
Microsoft MVP, Developer Evangelist, Author
Niloshima Srivastava
C# Corner MVP, Tech Architect, Trainer, Blogger
Bala Chirtsabesan
Senior Software Engineer at Microsoft, Author
Manoj Mittal
Sr. Technical Architect, C# Corner MVP, Author
Chandni Di
Co-Founder Voice of Slum
Vithal Wadje
Technical Lead, Microsoft MVP, Author
Shivam Ahuja
Founder SkillCircle, Business Mentor
Chervine Bhiwoo
Solution Architect, Microsoft MVP, Author
Saurabh Jain
Vice President Paytm, Founder Fun2Do Labs, Author
Vinay Solanki
Head IoT at Lenovo, Founder IoT-NCR
Anshu kumari
Founder Blockchainkids, Inventor, Trainer
Amit Singal
CEO Startup Buddy
Dev Pratap
Co-Founder & CEO Voice of Slum
Amey Vartak
Technology Consultant, Full Stack Developer, C# Corner MVP, Author
Viswanatha Swamy
Principal Software Engineer, C# Corner MVP, Author
Sanket Verma
Research Engineer @ Ballistics (Forensics) and Chair, PyData Delhi
Sourabh Somani
Lead Developer, Microsoft MVP, Author
Abhishek Mishra
Software Architect, C# Corner MVP, Author
Siddharth Vaghasia
Technical Consultant, C# Corner MVP, Blogger
Bassam Alugili
Senior Software Specialist, Database Expert
S Ravi Kumar
Solution Architect, C# Corner MVP, Author
Sundaram Subramanian
Full Stack Developer, C# Corner MVP, Speaker
Deepesh Somani
Solution Architect, Microsoft MVP, Author
Debasis Saha
Technical Project Manager, C# Corner MVP, Blogger, Author
Vipul Jain
Software Architect, C# Corner MVP, Author
Akshay Patel
Technical Architect, Microsoft Certified Trainer, C# Corner MVP, Author
Stephen Simon
RPA Developer, Evangelist, Author
Vivek Sharma
Founder Kingster636, AR/VR Specialist
Jeetendra Gund
Technical Lead, C# Corner MVP, Author
Sujal Beniwal
AI Enthusiast, Student
M Viknaraj
Microsoft MVP, Azure Architect, Author
Prasham Sabadra
Software Architect, C# Corner MVP, Trainer, Author
Aakash Maurya
Senior Developer, C# Corner MVP, Speaker
Ankit Sharma
Senior Software Engineer, C# Corner MVP, Author
Mangesh Gaherwar
Team Lead, C# Corner MVP, Author
Viral Jain
Technical Consultant, C# Corner MVP, Author
Bhasker Das
Solution Architect, Evangelist
Manish Dwivedi
Associate Project Manager
Ck Nitin
Programmer, Author
Rohit Gupta
Technical Trainer, Author
Manish Tewatia
Full-stack Marketer, UX Designer
Bhavya Gaur
Technical Illustrator
Rohit Tomar
SEO/SMO Expert
Web Track
Cloud & Data Track
Dev Track
Registration & Breakfast
Future of Desktop Apps with JS (ElectronJs)
Nitin Pandit
Building Serverless Microservices Using Microsoft Azure
Vithal Wadje
Innovating RPA: A Robot for Every Person
Stephen Simon
Managing Cloud Storage Accounts using Logic Apps
Viknaraj Manogararajah
Data visualization using Python
Sekhar Srinivasan
Going Cross platform with AR Foundation
Vivek Sharma
Keynote
Managing your Azure dependencies in ASP.NET Core apps using VS
Bala Chirtsabesan
Securing Applications on Intelligent Azure
Abhishek Mishra
Getting started with Blazor the Framework of Future
S Ravi Kumar
Lunch
Build Progressive Web Apps using Angular 9
Debasis Saha
Build and deploy to any platform using Azure DevOps
Chervine Bhiwoo
Deep Dive in Azure Service Bus
Akshay Patel
Build a Native Mobile Application using React Native and JavaScript
Joseph Guadagno
Making sense of Web Job, Web Job SDK and Functions in Azure
Prakash Tripathi
CloudFront Distribution in AWS
Viral Jain
Tea Break
Introduction to PowerBI
Aakash Maurya
Build Advanced SPFx solutions with React and Graph API
Siddharth Vaghasia
Build Business Intelligence Analyst (BIA) Skills
Sundaram Subramanian
Deep dive of Power Platform – AI BUILDER
Prasham Sabadra
Panel 1
What's new in SharePoint development
Vipul Jain
Build a SSO (Single Sign On) based Native JavaScript application with Microsoft Identity within 10 minutes
Manoj Mittal
Panel 2
Applications and working of AI
Veena Sarda
Deploying serverless API's with .Net core 3.0 on AWS & Azure
Amey Vartak
Panel 3
Blockchain with .NET Core (Ark)
Anshu Kumari
Closing Note & Prize Distribution
Dev Track
Cloud Track
Architecture Track
Emerging Tech Track
Registration & Breakfast
Creating Full-Stack Web Apps Using Server-Side Blazor
Ankit Sharma
Real time face recognition with MS Cognitive Services
Niloshima Srivastava
Building Scalable APIs with GraphQL
Jeetendra Gund
Future of development with AI and Blockchain
Navdeep Garg
Debugging Tips and Tricks with Visual Studio 2019
Joseph Guadagno
Azure Containers
Abhishek Kant
Enterprise Architecture
Naveen Sharma
Bot Framework - learn it fast and look like a boss!
Allen O’Neill
Keynote
.Net Core & C# 8 Performance
David McCarter
Working with Azure kubernetes services
Ritesh Modi
Becoming an Architect
Vidyavrat Agarwal
Why Techies Need to Learn Product Management
Saurabh Jain
Lunch
Build a rules engine in .Net Core
Sanjay Vyas
Building CI and CD Pipeline using Azure DevOps
Sandeep Soni
Entity Framework Core - Tips and Tricks, Performance Optimization, and Tuning
Bassam Alugili
Hacking your way into Data Science
Sanket Verma
Speed up your .Net Core Website
Sourabh Somani
Azure
Magnus Mårtensson
Demystifying Open Distro for Elasticsearch
Suman Debnath
Future of Data
Shivam Ahuja
Tea Break
gRPC with C# and .Net Core
Mangesh Gaherwar
Panel 1
Essentials of Cloud security
Parveen Malik
Power platform and Dynamics 365
Deepesh Somani
Microservices - the gRPC Way
Viswanatha Swamy
Panel 2
Reserved
Reserved
Closing Note & Prize Distribution
Replacing Switch Statements With the Strategy Pattern in C#
Switch statements feel comfortable at first. A handful of cases, a clear default, and the code reads fine on a Friday arvo when you're keen to ship before the long weekend. But the same construct tends to sprawl as the business grows. New payment providers, new shipping carriers, new discount tiers — each one nudges another case into a method that used to be tidy. In dev teams from Perth to Brisbane, this is a familiar refactor that ends up on the backlog more often than anyone would like to admit.
The Strategy Pattern offers a cleaner way forward. It lets you encapsulate each branch of behaviour behind a shared interface, then pick the right algorithm at runtime. For C# developers heading to the C# Corner Annual Conference 2020, the pattern fits neatly alongside discussions of SOLID principles, dependency injection, and the other refactoring tools that come up across the three-day agenda.
Why Switch Statements Creep Out of Control
A switch statement is fine when it represents a closed set of values the compiler can verify. The trouble begins when the set is actually open. A PaymentProcessor method that handles "CreditCard", "PayPal", and "BankTransfer" today will be asked to handle "Afterpay", "Klarna", and "ZipPay" tomorrow. Every new branch forces a change in code that should ideally be left alone.
This is the textbook violation of the Open/Closed Principle. The class is open for change, but only because someone has gone in with a screwdriver. Unit tests start duplicating each branch, code review gets noisy, and the merge conflicts pile up faster than a Melbourne tram in peak hour. Worse, the conditional logic often hides domain rules that deserve a proper home of their own rather than a corner of a switch block.
There is also a readability tax. A long switch buried in the middle of a service method is harder to step through than a polymorphic call. Tools like ReSharper and the latest Roslyn analyzers will flag switch blocks that exceed a certain size, but the real cost is cognitive. New starters at ANZ's tech hub in Melbourne or at Atlassian's Sydney offices spend their first week mapping these tangles before they can ship anything useful, and that ramp-up time shows up directly in sprint velocity.
What the Strategy Pattern Actually Solves
The Strategy Pattern is one of the original behavioural patterns from the Gang of Four. Its purpose is to define a family of algorithms, encapsulate each one, and make them interchangeable. In C#, that usually means an interface that declares the contract, concrete classes that implement it, and a context that holds a reference to whichever implementation is currently active. The pattern sits comfortably with delegates and Func<T> pipelines for simpler cases, and graduates to full interface hierarchies when the behaviour carries its own state.
What it really solves is the coupling between selection and execution. A switch statement does both in the same place: it selects a branch and runs the logic. The Strategy Pattern separates those concerns. Selection can live in a factory, a DI container, or a runtime lookup keyed on configuration. Execution lives in a small focused class with one job and a name that tells you exactly what it does.
This separation pays off in three concrete ways. First, you can add a new strategy without touching the existing ones, so the Open/Closed Principle is finally respected. Second, each strategy becomes trivial to test in isolation, which plays well with xUnit, NUnit, and the modern testing culture at Australian meetups like DDD Melbourne or the .NET user groups in Sydney and Adelaide. Third, the strategies themselves become reusable across other contexts — the same IExchangeRateProvider that powers the checkout flow can drive a back-office reconciliation job without duplication.
Comparing Switch Statements and the Strategy Pattern
| Aspect | Switch Statement | Strategy Pattern |
|---|---|---|
| Adding a new branch | Modify the existing method | Add a new class implementing the interface |
| Testability | Hard to isolate individual cases | Each strategy is unit-testable on its own |
| Readability | Degrades quickly past a handful of cases | Each class has a single clear responsibility |
| Runtime selection | Compile-time jump table | DI container, factory, or runtime lookup |
| Adherence to Open/Closed | Weak, requires editing existing code | Strong, existing code stays untouched |
| Discoverability | Hidden inside a method | Strategies are visible classes in your project |
The table is a useful starting point, but the real difference shows up the day someone asks for a new payment method on the morning standup. With a switch, the team knows it means another merge conflict and another branch of untested logic. With the strategy approach, someone can drop in a new file and register it, then grab a flat white while the build runs.
Implementing the Pattern in a Real C# Scenario
Imagine an order discount service that applies a different calculation depending on the customer tier: Bronze, Silver, Gold, and a new "Founders" tier that the marketing team in Sydney keeps inventing. The switch-based version packs all four formulas into one method, with magic numbers sprinkled around like Vegemite on toast and a default branch that quietly swallows unknown cases.
The strategy-based version starts with an interface that captures the contract:
public interface IDiscountStrategy
{
decimal Calculate(Order order);
}
Each tier gets its own class. A GoldDiscountStrategy might apply a percentage, a FoundersDiscountStrategy might combine a percentage with a fixed bonus, and a BronzeDiscountStrategy might be a simple flat rate. None of them know about each other, and each one can be reasoned about in isolation.
Selection happens in a factory that takes the customer tier and returns the right strategy, or even simpler, in the DI container registration where you map Enum → IDiscountStrategy. ASP.NET Core's built-in container, or libraries like Autofac and Lamar, handle this elegantly. A practical walk-through of using isolated environments for .NET work, similar to setting up Azure DevTest Labs for each strategy experiment, makes the local testing loop far smoother and keeps the build matrix clean.
The context class — often called the DiscountService — simply holds the chosen strategy and delegates the calculation. There is no switch, no if-else ladder, and no default branch that quietly swallows the unknown case. Unknown tiers can throw or fall back to a NoDiscountStrategy, and that fallback is itself a class you can test, swap, and version like any other piece of code.
When Strategy Makes Sense and When to Walk Away
The Strategy Pattern is not a free upgrade. It introduces more files, more types, and a slightly steeper onboarding curve for developers who have not worked with it before. For a switch that handles three values out of an enum the compiler can verify, the extra ceremony is overkill. The rule of thumb is to reach for Strategy when the cases represent behaviour, not data, and when that behaviour is likely to grow over time.
It also makes sense when the branch logic is genuinely complex. A simple switch (statusCode) that maps to an HTTP status description does not need an interface hierarchy. But a switch that triggers different workflows, side effects, or business rules absolutely does. If you find yourself passing the same context object into each branch, that is a strong smell that the branches want to be classes with their own dependencies and configuration.
Finally, keep an eye on performance. A switch on an integer compiles to a jump table that is faster than any interface dispatch in tight loops. For high-throughput code paths — order matching engines, hot telemetry pipelines, the kind of work done by teams at IC Markets in Sydney — the overhead of virtual dispatch is worth measuring with BenchmarkDotNet. For ordinary business logic, the cost is invisible and the maintainability gain is worth far more than a few nanoseconds.
Bringing this back to the C# Corner Annual Conference 2020, this is the kind of refactor worth tucking into your toolkit before you board the flight home. Sessions on design patterns, dependency injection, and modern C# language features all reinforce the same idea: write code that bends rather than breaks when the next requirement lands in your lap. The Strategy Pattern is one of the cleanest ways to keep that promise, and once you start using it, you will spot the places where a switch has been quietly doing the work of an entire class.
1, CBD, Maharaj Surajmal Road, Near Yamuna Sports Complex, Delhi, 110032
GENERAL QUERIES
Manish Tewatia
manish@csharpcon.com
+91-9718-431-042
TICKET QUERIES
Atul Gupta
conference@csharpcon.com
+91-9910-125-804