Imagine modelling an NBA (basketball) game. There are statistics
to keep tracked of for the player individually and for the team.
A naive way of implementing is:
A "Player" plays in a "Match" for team "Team" and generates
"PlayerStats". The team "Team" also generated "TeamStats" as a
result of the match.
How should I design "PlayerStats" and "TeamStats" so that:
a) I am flexible in only adding the "stat" that I've got confirmation on. Adding all possible stats as attributes of
class "PlayerStats" is not appropriate as I might not have the data for all of them. And adding new attributes will require a recompile.
b) no recompile of clientcode if add new attributes. Client code could be the admin
JSP pages that allow the stats to be loaded.
Any design
pattern come to mind ?
Cheers,
Pho