I am no OO expert, but I think the way that you have described it is good.

So long as you are explicitely passing in your components, I think calling 
methods on those components is the right way to go. 

Certainly this is preferable to any solution dependent upon inheritence (unless 
you really have an IS-A relationship - which I don't see in your example).

Steve Bryant
Bryant Web Consulting LLC
http://www.BryantWebConsulting.com/
http://steve.coldfusionjournal.com/ 

> In my long struggle to get my head around OOP principals, I've been 
> playing with a card game application.  And I have a question of how 
> one uses composition and best practices.
> 
> To layout the scenario, I currently have the following CFCs:
> 
> Card: 
> Rank
> Suit
> Description
> 
> Deck:
> array of Cards
> Shuffle()
> Deal()
> 
> Hand:
> Array of Cards
> addCard()
> removeCard()
> 
> Player:
> HAND
> receiveCard()
> showCards()
> 
> Table
> DECK
> Array of Players
> addPlayer()
> removePlayer()
> deal()
> 
> My question is about calling functions on component objects composited 
> inside of other component objects.  For example, during the play of a 
> game, it is time for players to play a card, removing it from their 
> hands.  What is the best practice to tell the table to get a card from 
> all the players?  
> 
> Do you write a getCard() function in table that calls a getCard() 
> function in player that calls the Hand.removeCard() function.  
> 
> That just seems a bit tightly coupled, but I can't think of any other 
> way to go about it.
> 
> --------------
> Ian Skinner
> Web Programmer
> BloodSource
> www.BloodSource.org
> Sacramento, CA
> 
> ---------
> | 1 |   |
> ---------  Binary Soduko
> |   |   |
> ---------
 
> 
> "C code. C code run. Run code run. Please!"
> - Cynthia Dunning
> 
> Confidentiality Notice:  This message including any
> attachments is for the sole use of the intended
> recipient(s) and may contain confidential and privileged
> information. Any unauthorized review, use, disclosure or
> distribution is prohibited. If you are not the
> intended recipient, please contact the sender and
> delete any copies of this message. 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:260563
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to