jmarceli / scoreboard

Repository from Github https://github.comjmarceli/scoreboardRepository from Github https://github.comjmarceli/scoreboard

README

license

Task description

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:

  1. 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
  2. Update score. This should receive a pair of absolute scores: home team score and away team score.
  3. Finish match currently in progress. This removes a match from the scoreboard.
  4. 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.

Assumptions

  1. Football matches removed from the Scoreboard are no longer relevant and lost forever
  2. Match IDs are not implemented but could be added if required e.g. by storage engine based on team names
  3. Library exposes relevant interfaces to be implemented in order to use Scoreboard with sports different from football
  4. 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
  5. 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
  6. There is no check if match score exceeds max value of Integer

Setup

Code is formatted using google-java-format use plugin appropriate for your IDE.

Project is using Java 21 - Amazon Corretto 21.0.6

Packaging

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>

TODO

Future enhancements:

  • Extract Score interface and implement FootballScore class in domain model to extract score validation logic to a dedicated class adhering to Single Responsibility principle
  • Create MatchFactory interface and FootballMatchFactory class to facilitate match creation and offload match creation logic from Scoreboard class
  • Create ScoreboardValidator class to extract validations from the main Scoreboard 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

License

MIT

Author

Jan Grzegorowski

About

License:MIT License


Languages

Language:Java 100.0%