[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Design question

Srijayanth Sridhar

5/6/2009 1:05:00 PM

[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

4 Answers

Robert Klemme

5/6/2009 2:31:00 PM

0

2009/5/6 Srijayanth Sridhar <srijayanth@gmail.com>:
> 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

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestprac...

The Peeler

4/2/2014 4:04:00 PM

0

On Wed, 2 Apr 2014 14:35:58 +0200, Dumb Heini, the heavily medicated Dutch
resident Nazi troll and laughing stock of sci and scj, wrote:

>> Maybe Muslim attacks against Christians will stop then.
>> https://www.youtube.com/watch?v=-...
>>
>> How to support Israel
>> http://unitedwithisrael.org/how-to-support-isra...
>>
>> Israel fights Jihad and wins!
>>
>>
>>
>
> go away.stop polutting this ngroup

Who allowed you to oink at humans in a humans-only newsgroup, Dutch PIG?


--
Dumb Dutch Nazi Heini's motto: "to suck rectum or not to suck rectum that is
the question"
MID: <4db7abbb$0$24816$2e0edba0@news.tweakdsl.nl>

The Revd

4/2/2014 9:53:00 PM

0

On Wed, 2 Apr 2014 05:28:41 -0700 (PDT), Grikboxer?? the Grik piece of
skata aka diarrhoea19@gmail.com wrote:

>?? ???????, 2 ???????? 2014 2:28:21 ?.?. UTC+3, ? ??????? Heinrich ??????:
>> Jews are Winning in the USA
>
>Maybe Muslim attacks against Christians will stop then.
>https://www.youtube.com/watch?v=-...
>
>How to support Israel
>http://unitedwithisrael.org/how-to-support-isra...

Greek 'Israel' and greek you, asshole!

>Israel fights Jihad and wins!

Eye-ran makes nukes and bombs 'Israel' back to the Stone Age!

Harold Burton

4/2/2014 11:01:00 PM

0

In article <sk1pj99bf3mvmt3ivgv3ao14mugog8uph4@4ax.com>,
The Revd <peeling@degenerate.Grik> wrote:


> Eye-ran makes nukes and bombs 'Israel' back to the Stone Age!

Hahahahahahahahahahahaha. Iran hasn't a prayer of doing that, but they
have a very good chance of getting their country's surface turned to
fused glass.



laugh . . . laugh . . . laugh