We have covered how to create a small project in Scala from scratch to packaging. We used TDD along the way so that it is guaranteed that our code was well-designed and robust. It gives us confidence when we refactor code: as long as all tests pass, we know that our code stills works. We modeled our domain with immutable data structures and processed them using pure functions that have no side effects.
We used some basic features of the language that are used in most projects, and you should now be familiar with enough building blocks to implement a wide variety of projects.
As a further exercise, you could enhance this calculator with one or many of these features:
- Create an app for the function
RetCalc.nbOfMonthsSaving
, which calculates how long you need to save before you can retire. - Create a function called
RetCalc.annualizedTotalReturn
, which calculates the geometric average of a sequence of returns. See https://www.investopedia.com/terms/a/annualized-total-return.asp for more details...