Game
In the code you shared, you never use the setters of the Game
class. How about making its fields final
and removing the setters? Immutable things are simple, robust, and great. It would be greatIt's best to make everything immutable thatas much as you can.
Also, do you really need the empty constructor?
GameRepository
In getGameById
and updateGame
you iterate over a list of games. How about using a Map
of id -> Game
instead? It would seem a lot more natural, and at the same time more efficient.
Formatting
Overall the code is well readable. The one thing where you violate the standard is spaces around braces and parentheses:
for(Game game : games){ if(game.getId() == id){
The standard (Eclipse does it with Control-Shift-f
) would be:
for (Game game : games) {
if (game.getId() == id) {