Skip to content

Conversation

@NamCap99
Copy link

…turns

@NamCap99 NamCap99 changed the title Refactor ProcessPayment: guard clauses, ApplyPayment helper, early re… Refactor ProcessPayment method for cleaner code and better structure May 26, 2025
@NamCap99
Copy link
Author

Overview

I refactored the ProcessPayment method to make the code easier to read, understand, and maintain.

What I changed

  • Replaced long nested if-else statements with early return checks
  • Moved repeated logic into a new ApplyPayment helper method
  • Made sure the Payments list is always initialized to avoid null errors
  • No business logic was changed — it still works the same
  • All 9 unit tests passed after the update

Why

The original method was quite hard to follow and had duplicate code. I wanted to clean it up and make it easier for others (and myself) to work with in the future.

Notes

  • I upgraded the project to .NET 6 to get modern features and support
  • I kept all the original files and structure, as asked
  • Added NUnit dependencies to run and pass all existing tests

@NamCap99
Copy link
Author

@re-leased-hiring This pull request is ready for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant