Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vladimirlogachev/transitive-closure
Coding assessment (Scala 3, Cats, ScalaTest) 2019
https://github.com/vladimirlogachev/transitive-closure
Last synced: 19 days ago
JSON representation
Coding assessment (Scala 3, Cats, ScalaTest) 2019
- Host: GitHub
- URL: https://github.com/vladimirlogachev/transitive-closure
- Owner: vladimirlogachev
- Created: 2019-10-07T15:39:46.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-11-02T05:32:34.000Z (about 2 months ago)
- Last Synced: 2024-11-30T05:28:57.611Z (24 days ago)
- Language: Scala
- Homepage:
- Size: 30.3 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# transitive-closure
Coding assessment (Scala 3, Cats, ScalaTest).
Completed in 2019, and currently maintained as a demonstration project.
## Pre-requisites
- [sbt](https://www.scala-sbt.org/)
## Usage
- `sbt test` - test
- `sbt styleFix` - fix formatting and linting errors
- `sbt styleCheck` - check for formatting and linting errors
- `sbt dev` - allow compiler warnings to not fail the compilation## Objective
A database contains `Foo` items, and all their `references` do exist in db. One can use `FooRepository` interface to interact with db.
The task is to implement a `readClosure` function, which accepts a list of `FooId` and returns them and all objects which they refer to (directly or indirectly). The function should be tested with mock implementations of `FooRepository` (which should also be developed).
## Technical decisions
### 1. Tail recursive monadic function is used
This allows large relation graphs
### 2. Cyclic relations are allowed
Items can refer to each other in any order
### 3. Each item will be requested exactly once
This was not required by the objective. However, since all elements are merged in a single Set, there will ever be no need in fetching some element twice, that's why this restriction was added (and tested). Also this makes sense in case of ring-like relations.