Re: Deck of Cards Question...
- Posted by George Henry <ghenryca at HOTMAIL.COM> Nov 21, 2000
- 435 views
OOP is based on the idea that "data knows what to do." If data knows what to do, then I am not needed as an implementor of algorithms. I will just decide what data are relevant, then describe my goals to them and let them do what needs to be done. 8^) Not that OOP is all bad (14 zillion programmers can't be wrong, can they?), but sometimes it's just silly. So, when OOP is successfully combined with "declarative programming" (ala Prolog, perhaps?) maybe I will like it better. Give me data that REALLY DOES know what to do! How does Euphoria encourage global variables? I don't feel encouraged to use them, except as simple control flags where "ctrl_flag=1" is equivalent to, but more straightforward than, "set_ctrl_flag()" (and similarly for "ctrl_flag=0" vs. "clear_ctrl_flag()"). Euphoria itself encourages me to use the function method. Euphoria doesn't let one pass a reference or pointer, so "append(seq1, seq2)" wouldn't do the job as a statement, it has to be a function, and following that model makes sense and is good practice. George Henry ----Original Message Follows---- From: Derek Parnell <derekp at SOLACE.COM.AU> Reply-To: derekp at solace.com.au To: EUPHORIA at LISTSERV.MUOHIO.EDU Subject: Re: Deck of Cards Question... Date: Mon, 20 Nov 2000 12:16:55 +1100 I like OOP so I'd tend towards that, but the second suggestion,... shuffled_deck = shuffle(deck) is okay too. Global variables, like GOTO, can easily be misused and cause weird bugs. Its a bit unfortunate that Euphoria encourages them, but until namespace and forward referencing issues are finalized, we have to live with this little "devil". Also, the function method makes it easier to implement non-standard decks (short or enlarged ones, for example.). shuffled_deck = shuffle(deck & deck) shuffled_deck = shuffle(deck[Spade04 .. SpadeAce] & deck[Club04 .. ClubAce]) ----- cheers, Derek Parnell _____________________________________________________________________________________ Get more from the Web. FREE MSN Explorer download : http://explorer.msn.com