This PR refactors the LegacyApp to adhere to SOLID principles (Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion), KISS (Keep It Simple, Stupid), YAGNI (You Ain't Gonna Need It), DRY (Don't Repeat Yourself), and clean code practices.
Changes Made
Created a new class ClientService to handle interactions with the ClientRepository.
Created a new class UserCreditServiceWrapper to wrap the UserCreditServiceClient.
Created an interface ICreditLimitCalculator and concrete implementations in the CreditLimitCalculators directory for each type of client to calculate the credit limit.
Refactored the AddUser method in the UserService class to use the new classes and interfaces.
Injected dependencies through the constructor or setter methods to adhere to the Dependency Inversion Principle.
Removed the code that directly interacted with the ClientRepository and UserCreditServiceClient to improve testability and flexibility.
Description
This PR refactors the LegacyApp to adhere to SOLID principles (Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion), KISS (Keep It Simple, Stupid), YAGNI (You Ain't Gonna Need It), DRY (Don't Repeat Yourself), and clean code practices.
Changes Made
ClientService
to handle interactions with theClientRepository
.UserCreditServiceWrapper
to wrap theUserCreditServiceClient
.ICreditLimitCalculator
and concrete implementations in theCreditLimitCalculators
directory for each type of client to calculate the credit limit.AddUser
method in theUserService
class to use the new classes and interfaces.ClientRepository
andUserCreditServiceClient
to improve testability and flexibility.Checklist
UserService
class and itsAddUser
methodRelated Issue
Refactor to use SOLID principles, KISS, YAGNI and DRY as well as clean code
Fixes #1.
To checkout this PR branch, run the following command in your terminal: