Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
private static void ProcessPayments()
var paymentProviders = new[] {
"Paypal", "ApplePay", "GooglePay",
"Braintree", "PayPal", "ApplePay",
"ApplePay", "BadPaymentProvider" };
foreach (var paymentProvider in paymentProviders)
var paymentProcessor = PaymentStrategyFactory.Create(paymentProvider);
WriteLine($"===== Processing with '{paymentProvider}' Provider =====");
// There is no need to check if the payment processor is null here
// Reduced Cyclomatic Complexity.
var paymentStatus = paymentProcessor.Process(111);
WriteLine($"--> {paymentStatus}");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment