-
Notifications
You must be signed in to change notification settings - Fork 503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Graeme Hedges - Backend Task (Exchange Rate Updater .NET) #674
Open
GraemeHedges
wants to merge
35
commits into
MewsSystems:master
Choose a base branch
from
GraemeHedges:feature/adding-czech-national-bank-exchange-rate-provider
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Graeme Hedges - Backend Task (Exchange Rate Updater .NET) #674
GraemeHedges
wants to merge
35
commits into
MewsSystems:master
from
GraemeHedges:feature/adding-czech-national-bank-exchange-rate-provider
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…eRateService test passes
…DTO, used in ExchangeRatesDTO
…ary), added Hosting and HTTP to allow for IHttpClientFactory implementation
…ded interface, changed transient service registration to use interface
…t for non success response
…tern, changed tests to suit new pattern
…ateService to use todays date, Removed temp ExchangeRateUpdater
…y when results returned, added tests
…ges, now runs and refreshes on key press
…, fixed tests now that Provider is async again, added resiliance
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Task
This PR addresses the requirement to implement an exchange rate provider for the Czech National Bank, using their publicly available APIs to source the exchange rate data for specifically requested currencies. The currencies are to be returned to the user in a console application.
Approach
I have approached this task with the idea of creating an MVP that satisfies the requirements. That means that I have retained the console application, and extended it's functionality to return the required data. My main focus was to keep the code clean, clear and SOLID so as to be easily maintainable and extensible. I had considered replacing this console application with a minimal API for example, but in the end decided that my focus here should be on delivering the requirements as written. I expect that this program would eventually service a number of front ends and at that point, adding an API would be more appropriate.
I have implemented logging and caching - these are simple implementations appropriate for a console application. For logging, I have kept log messages clear and simple, with only one log instance requiring structured logging. These logs are simple console logs. In a production app, I would expect to connect to a provider such as application insights. Similarly, for the caching that is a simple in memory cache - it would be preferable to implement a separate caching source running independently
from the main application, such as Redis for example, to increase the resilience of the cache. I have set a short time to live for the purposes of this test, but in a real world solution would probably look to refresh the cache inline with source API.
I have added unit tests for updated Provider and Service classes. For the sake of brevity I have used multiple asserts in each test scenario, as I believe that keeps test code clearer and easier to read, without sacrificing testing the classes logic. Although not always the most reliable of metrics, both of these classes do have 100% code coverage.
More generally, I have updated the project to .NET 8, and brought the program.cs file in line with modern coding approaches. I have used global usings to reduce 'noise' in files, and have used file scoped namespaces to make the code easier to read. I have used IHttpClientFactory to create the HttpClient and type it, as well as added standard resilience handling to deal with failed calls. In short, I have applied modern .NET coding practices where possible.
Improvements