https://github.com/dotmh/language-learning
A scenario used to learn new programming languages
https://github.com/dotmh/language-learning
deno dotmh go kotlin learning nodejs typescript
Last synced: 3 months ago
JSON representation
A scenario used to learn new programming languages
- Host: GitHub
- URL: https://github.com/dotmh/language-learning
- Owner: dotmh
- License: apache-2.0
- Created: 2023-06-06T13:00:43.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-29T16:44:32.000Z (over 1 year ago)
- Last Synced: 2025-03-27T18:18:16.746Z (about 1 year ago)
- Topics: deno, dotmh, go, kotlin, learning, nodejs, typescript
- Language: C#
- Homepage:
- Size: 157 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
- Support: support/api/api.ts
Awesome Lists containing this project
README
# Language Learning Scenario
## About
I enjoy learning new languages in pursuit of that goal I came up with a basic scenario that I could use to explore new languages and frameworks.
The idea of the scenario is that it is simple enough to not require in depth knowledge of the language so making it easier to learn the language. It also can cover some common tasks that I would need to do as a front end developer.
## The Scenario
You have returned from a 2 week trip in Japan. You didn't spend all the money that you convert to the Japanese Yen (¥) to take with you. You there for have a wallet fall of Japanese currency. The task is to covert the ¥ amount back to British Pound Sterling (£).
### The code should
1. take in the amount of each coin or note that you have.
2. show a summary of the wallet totals i.e. how much value of each coin or note you have
3. get the total in ¥
4. get the current exchange rate from [Free Currency API](https://freecurrencyapi.com) for ¥ to £.
5. display the total in ¥ and in £ to 2 decimal places.
### Wallet Contents
#### Notes
- 5 x ¥10,000 notes
- 1 x ¥5000 note
- 5 \* ¥1000 notes
#### Coins
- 1 x ¥500 coin
- 4 x ¥100 coins
- 5 x ¥50 coins
- 8 x ¥10 coins
- 7 x ¥5 coins
- 14 x ¥1 coins
## Scope
### Reducing Scope
This is already a simple task, but with some languages or situations making HTTP requests can be very complex.
You can therefore reduce scope by removing the part around getting a live conversion rate for ¥ to £.
You then replace the live exchange rate with a fixed value.
### Extending Scope
There are number of ways that scope can be expand
#### User Input
As an example app, having the wallet (the amount of coins and notes that you have) hardcoded is fine
but in the real world it would be better to allow the user to input that data. so you could add
- allow the program to loop through each note and coin and ask the user how much they have.
#### Graphical User Interface
The next cool step might be to add a Graphical User Interface (GUI). Real Users prefer a GUI as they find Command Line Interface (CLI) apps much more intimidating. In this case you might add
- show the user graphical the total in ¥ and in £
you could also combine this with the first scope extension to allow the user to enter the how much of
each coin or note they have inside your GUI.
- allow the user to add how much of each coin or note they have using the GUI.
#### Expanding the Currencies
The Current app is very much focused on a single purpose that off converting ¥ to £ but to expand it
in to a much more useful application might be to add in extra currencies. This could take the form of
adding extra currencies to convert from , extra currencies to convert too or both. This is the least
interesting from a coding point of view because it will be more about Data. You would need to get
all the different coins and notes used by each currency.
The biggest logic change will be handling the sub unit of currencies used by some currencies such as
Cents (¢) on the Dollar ($) or pence (p) on the Pound (£). Although again this is pretty simple as almost all
currencies have a 100 sub units of currency to the main.
With all of these scope extensions added together you would have a full app that could be useful for
any user.
- Allow the user to change which currency they want to convert to
- Allow the user to change which currency the user wants to convert from
- Show the correct Notes and Coins for the currency the user has chosen to convert from.
## API
You can get the above data, as well as Japanese coin and note denominations from an API endpoint.
Make a [HTTP GET](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET)
request to
[](/support/api/api.ts)
## Implementations
Please note these implementations (with the exemption of Typescript) are all created while learning and so may not reflect best practise. These are not intended to be definitive examples of each language.
[](/typescript/node/index.ts)
[](/kotlin/currency-convertor/src/main/kotlin/Main.kt)
[](/go/currency.go)
[](cs/curreny-calculator/)
### Notes for running
#### Environment Variables
All examples expect the API key for [Free Currency API](https://freecurrencyapi.com) to be stored in the Environment variable `FREE_CURRENCY_API_KEY`