# Design question

**URL:** <https://www.ruby-forum.com/t/design-question/167295>\
**Category:** Ruby\
**Created:** [May 6, 2009, 3:05pm UTC](https://www.ruby-forum.com/t/design-question/167295 "2009-05-06T15:05:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Srijayanth\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e95f7d/32.png) [@Srijayanth\_S](https://www.ruby-forum.com/u/Srijayanth_S)\
**Post date:** [May 6, 2009, 3:05pm UTC](https://www.ruby-forum.com/t/design-question/167295/1 "2009-05-06T15:05:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Srijayanth\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e95f7d/32.png) [@Srijayanth\_S](https://www.ruby-forum.com/u/Srijayanth_S)\
**Post date:** [May 6, 2009, 4:32pm UTC](https://www.ruby-forum.com/t/design-question/167295/2 "2009-05-06T16:32:02Z")

</div>

2009/5/6 Srijayanth S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> 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
