Design question

  • Thread starter Srijayanth Sridhar
  • Start date
S

Srijayanth Sridhar

[Note: parts of this message were removed to make it a legal post.]

Hello,

I am building a simple tool to help with some statistical analysis of a
sports site. I have the following:

class Player # just a wrapper around ostruct for read_only access
class Team # a collection of players
class League # a collection of teams

There are many ways I can "build" the league so to speak. I want to be able
to build the league from a web site(scraping for information), from a DB(for
local access) and a file(for even more local access I suppose). Now I am
having a bit of a problem organizing a few things.

Should I have an abstract class Builder and derive WebBuilder, DBBuilder,
and FileBuilder from it or should I just have different methods within the
league class? If I were to make these separate classes, then the builder
class will have to somehow get the data back across to the League class
which actually builds the team. It feels a bit kludgy. I don't want to
burden the Team and Player's constructors with any more than just basic
assignments. Is this a bad idea?

And the bigger fish here is the web builder. The web builder has to screen
scrape a site with a list of teams, from which it goes to each team page,
and further fetches statistics by going to the player's site. Its really
elementary to do, but again, where should it ideally fit?

Thank you,

Jayanth
 
R

Robert Klemme

2009/5/6 Srijayanth Sridhar said:
I am building a simple tool to help with some statistical analysis of a
sports site. I have the following:

class Player # just a wrapper around ostruct for read_only access
class Team # a collection of players
class League # a collection of teams

There are many ways I can "build" the league so to speak. I want to be able
to build the league from a web site(scraping for information), from a DB(for
local access) and a file(for even more local access I suppose). Now I am
having a bit of a problem organizing a few things.

Should I have an abstract class Builder and derive WebBuilder, DBBuilder,
and FileBuilder from it or should I just have different methods within the
league class?

Definitively decouple the stuff into several other classes and do not
do it with a bunch of methods!
If I were to make these separate classes, then the builder
class will have to somehow get the data back across to the League class
which actually builds the team. It feels a bit kludgy. I don't want to
burden the Team and Player's constructors with any more than just basic
assignments. Is this a bad idea?

And the bigger fish here is the web builder. The web builder has to screen
scrape a site with a list of teams, from which it goes to each team page,
and further fetches statistics by going to the player's site. Its really
elementary to do, but again, where should it ideally fit?

From what you write I conclude (although not 100% sure) that you have
read only access to all the data storage variants (at least for web
this sounds reasonable). This is certainly a point that needs
clarification.

Note, I haven't used ActiveRecord so far but I would probably use that
(or any other OO mapper) to do the DB binding. Then I'd try to model
the file and web bindings with a similar interface. Dunno whether
this is feasible but at least worth exploring.

Kind regards

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top