-
Notifications
You must be signed in to change notification settings - Fork 0
/
DesignNotes.txt
26 lines (21 loc) · 1.61 KB
/
DesignNotes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Explanation of decisions and design
===================================
- Used Gradle (dependency management, build and test) and a mix of Java and Kotlin for this solution.
Java is my most familiar language and I used Kotlin where Java has limitations - for tail-recursion
optimisation and for the ZIP stream function.
- Implemented the Collatz series with tail-recursion in Kotlin which optimises tail-recursive functions.
Used BigInteger for the input, output and intermediate term values. This allows arbitrarily large
series tests without risk of stack overflow or number out of range problems.
- I chose Spark Java (sparkjava.com) as the HTTP server framework for building the REST API Controller.
It is a lightweight framework/library which can be dropped into the application. I prefer this over
heavier enterprise frameworks such as Spring Boot where possible (although I'm happy to use
Spring Boot when required). Spark has low memory usage , see:
https://craftsmen.nl/memory-usage-6-popular-rest-server-frameworks-compared/
and has performance comparable to it's underlying Jetty server.
If required, the Controller implementation can be swapped out with another server implementation
without affecting the rest of the implementation.
- I chose the REST Assured test framework for integration testing of the REST API. The syntax is
declarative and concise and the tests can be automated as plain JUnit tests and run
with Gradle.
- Collatz term calculations are delegated to a Thread Pool Executor and I chose a synchronised
Map for caching results as this allows safe multi-threaded access.