• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

[ modelling a sport's statistics ] Comments ?

 
Ranch Hand
Posts: 782
Python Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nice brain-teaser, Pho
I am going to come up with some solution by this week-end.As regards Design Patterns, I think we need to use Expert Pattern, High Cohesion to come up some design.
Food for thought!

  • Can we design an association (not aggregation/composition) between Player and PlayerStat class.
  • Can we design this solution on a Model-View pattern wherein we may have a JSP as a view, which presents a query to the user (say Team1 details).The servlet (Model) interprets the request and processes it with the help of Java Bean to serve the request.The servlet then passes the information to the view.

  • Looking forward for your comments/suggestion on this interesting problem.
    Regards,
    Sandeep
 
Pho Tek
Ranch Hand
Posts: 782
Python Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Desai and all,
Can someone comment on what I've done here. I'm still
a bit blur on the creation of "ASSOCIATION CLASSes". So this
attempt is based on code taken from jguru. Let me know if
this wrong, right etc.. and how can I improve this:-


Pho
[This message has been edited by Pho Tek (edited December 22, 2001).]
 
reply
    Bookmark Topic Watch Topic
  • New Topic