You are working in a sports data company, and we would like you to develop a new Live Football World Cup Scoreboard library that shows all the ongoing matches and their scores.
The scoreboard supports the following operations:
- Start a new match, assuming initial score 0 – 0 and adding it the scoreboard.
This should capture following parameters:
- a. Home team
- b. Away team
- Update score. This should receive a pair of absolute scores: home team score and away team score.
- Finish match currently in progress. This removes a match from the scoreboard.
- Get a summary of matches in progress ordered by their total score. The matches with the same total score will be returned ordered by the most recently started match in the scoreboard.
- Football matches removed from the Scoreboard are no longer relevant and lost forever
- Match IDs are not implemented but could be added if required e.g. by storage engine based on team names
- Library exposes relevant interfaces to be implemented in order to use Scoreboard with sports different from football
- Match score is always integer which is valid in case of football but might be a limitation when it comes to extending Scoreboard functionality, thus Score interface is listed as one of possible improvements
- Team is identified only by its name and name is case-sensitive so it is valid that "France" is playing with "france", to be improved in future
- There is no check if match score exceeds max value of Integer
Code is formatted using google-java-format use plugin appropriate for your IDE.
Project is using Java 21 - Amazon Corretto 21.0.6
Execute maven package
to build library JAR.
For local testing make sure to manually include logback-classic as dependency:
<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.16</version>
</dependency>
<dependency>
<groupId>com.grzegorowski.scoreboard</groupId>
<artifactId>scoreboard</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>/absolute/path/to/target/scoreboard-1.0-SNAPSHOT.jar</systemPath>
</dependency>
</dependencies>
Future enhancements:
- Extract
Score
interface and implementFootballScore
class in domain model to extract score validation logic to a dedicated class adhering to Single Responsibility principle - Create
MatchFactory
interface andFootballMatchFactory
class to facilitate match creation and offload match creation logic from Scoreboard class - Create
ScoreboardValidator
class to extract validations from the mainScoreboard
class following Single Responsibility - Ensure that
FootballTeam
names are case in-sensitive when it comes to making sure that given team is not currently playing match - Ensure code formatting validation before push
- Ensure CI pipeline to validate code coverage, possible code or dependencies security issues or secrets commited to the codebase etc. in every Pull Request
- Ensure CD pipeline to publish library to selected repository
Jan Grzegorowski