[Newbies] Where do I put it?
Ron at USMedRec.com
Tue Mar 6 14:04:23 UTC 2007
I agree that you questions have general value and I'm happy to help
publicly. I only offered to help you offline because it is clear that you
are getting something from our conversation so I wanted to remove the
distractions of the public list if it was causing any difficulty.
It does seem that there are games where the deck arrangement is so different
that it needs its own coding. The benefit of the factory implementation
that I showed you is that you now have a deckFactory superclass to write
code that is common among all decks (like shuffle). Ultimately the greatest
benefit of shared code comes from having more then one game that can use the
same deck. In that case all you have to do is implement the deckType on
your game and you are good to go.
You are asking very good questions, please keep them coming!
> -----Original Message-----
> From: Blake
> On Mon, 05 Mar 2007 08:20:39 -0800, Ron Teitelbaum <Ron at USMedRec.com>
> > I just wrote all this off the top of my head and didn't test any of it,
> > and I didn't include all the code you need. I guess I'm just giving you
> > a
> > pattern that will work, but that leaves you plenty to learn on your
> > own. I tried to make it simple, but I've been told that I don't do that
> > very well. So if you need a more detailed explanation I can go over
> > each step in my
> > thinking, please don't be afraid to ask. If you like we can continue
> > this conversation offline, either way works for me.
> Well, I hope the questions I post have some general educational value. I'm
> building mini-Smalltalk lessons and decided to do a series on card games
> because when =I= was learning, each game defined its own deck of cards
> with its own set of code. (If suit wasn't important to a game, for
> example, the program simply wouldn't specify it.) Lotta duplicated
> read-only code. A deck of cards seemed like a good, beginning design
> question, but I began to think (overthink?) the relationships of physical
> cards, decks, the symbols used, etc.
> I hadn't thought of using a factory; I'll brood on that one.
More information about the Beginners