This PR refactors the legacy project to adhere to SOLID principles (Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, and 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 IClientRepository interface with a GetById method.
Created IUserCreditServiceWrapper interface with a GetCreditLimit method.
Created IUserDataAccess interface with an AddUser method.
Implemented IClientRepository interface in ClientRepository class.
Created UserCreditServiceWrapper class that implements IUserCreditServiceWrapper interface and wraps UserCreditServiceClient.
Implemented IUserDataAccess interface in UserDataAccess class.
Refactored UserService class to use the newly created interfaces.
Broke the AddUser method into smaller, more manageable methods.
Used constructor injection to get the dependencies.
Checklist
[x] Created IClientRepository interface
[x] Created IUserCreditServiceWrapper interface
[x] Created IUserDataAccess interface
[x] Implemented IClientRepository interface in ClientRepository class
[x] Created UserCreditServiceWrapper class
[x] Implemented IUserDataAccess interface in UserDataAccess class
[x] Refactored UserService class
[x] Broke AddUser method into smaller methods
[x] Used constructor injection for dependencies
Additional Notes
The IUserCreditService and IUserCreditServiceChannel interfaces and the UserCreditServiceClient class are generated code and were not modified.
The code within LegacyApp.Consumer was not changed as per the request.
Please review and merge this PR. Thank you!
Fixes #1.
To checkout this PR branch, run the following command in your terminal:
Description
This PR refactors the legacy project to adhere to SOLID principles (Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, and 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
IClientRepository
interface with aGetById
method.IUserCreditServiceWrapper
interface with aGetCreditLimit
method.IUserDataAccess
interface with anAddUser
method.IClientRepository
interface inClientRepository
class.UserCreditServiceWrapper
class that implementsIUserCreditServiceWrapper
interface and wrapsUserCreditServiceClient
.IUserDataAccess
interface inUserDataAccess
class.UserService
class to use the newly created interfaces.AddUser
method into smaller, more manageable methods.Checklist
IClientRepository
interfaceIUserCreditServiceWrapper
interfaceIUserDataAccess
interfaceIClientRepository
interface inClientRepository
classUserCreditServiceWrapper
classIUserDataAccess
interface inUserDataAccess
classUserService
classAddUser
method into smaller methodsAdditional Notes
IUserCreditService
andIUserCreditServiceChannel
interfaces and theUserCreditServiceClient
class are generated code and were not modified.LegacyApp.Consumer
was not changed as per the request.Please review and merge this PR. Thank you!
Fixes #1.
To checkout this PR branch, run the following command in your terminal: