O'Reilly Forums: Day At The Races - Design Logic Question - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Day At The Races - Design Logic Question Rational behind the design of Day at the Races given in the book

#1 User is offline   AnanthBV 

  • New Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 13-March 13

Posted 13 March 2013 - 09:22 AM

Hi,

I'm trying to learn C# from the book Head First C#.

I have a question on the design suggested for Lab 1 - Day at the Races.

It is suggested that we use a Guy, Greyhound and a Bet class where each Guy will have his own Bet class to place the bet and receive payout.

1. I am finding it difficult to understand why exactly we need to have a Bet class reference inside the Guy class. Can we have something like a BettingParlor class which keeps track of who has placed the bet and does payout once the race is over?

2. Why do we need to have a reference to the radiobutton and the label from inside the Guy class? Can't we modify the radiobutton and the label class from the main form itself?

In general, is there any way to decide what classes we need to have for a given problem?

Could someone kindly help out with the above questions?
0

#2 User is offline   CastSeven 

  • New Member
  • Pip
  • Group: Members
  • Posts: 4
  • Joined: 05-August 12
  • Gender:Male
  • Location:Southern California
  • Interests:Video Game & Software Development, Aviation

Posted 08 May 2013 - 01:13 AM

One thing you'll learn about programming - especially .NET: there are many different ways to do things, and there often isn't any one "correct" way.

It's been a while since I've looked at that particular exercise, but just off the top of my head, both ideas sound completely feasible to me. I couldn't tell you why the writer of the book went with one implementation over the other, in part they're also trying to cater to the expected skill level at that point in the book, but I can tell you that I could think of about a thousand other ways to implement it too.

In a more complex application, there would be more variables to consider when deciding on an implementation (how other components will work together, performance, thread safety, etc) that could limit your choices more, but with "day at the races" there are a lot of options.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users