On 12/31/2013 09:46 PM, Keith Winston wrote:
Thanks Denis, I found out about the iter builtin last night, a few hours
after I'd coded/posted that. Oops. Thanks for your other comments, I am
clearer now about the distinction of creating a new, empty list vs.
clearing the same list out, and the subsequent implications on other
symbols bound to the same list (is that the right language?).

Thanks, thus I did not spoil my time ;-)

Not to beat a dead horse: you mention the name of the "game" method: in my
code, "game" plays a game of Chutes & Ladders (does a series of moves until
the game is over), compiles the statistics from said game, and passes
those, as a list of ints & lists, to be gathered into a list of lists at
the next level ("games" is the list of lists, composed of many "game"
lists). I should absolutely document it better, but does that still not
seem like a good name to you? Thanks for your feedback.

In the part you showed us, unless my memory trumps myself, the method barely collected stat data _about_ the game. I did not look like representing the game's *playing* globally. But indeed, it was probably only a snippet.

Well, actually the case looks ambiguous. If at all possible, i would separate in a sub-method the piece of code that compiles statistic data. Call it stats or game_stats or whatever looks clear and correct. The super-method that plays the game and, as an after-thought (even if it's not the case for you) calls this sub-method that collects data _about_ the game, may be called 'play'. This, because the whole of the app is, conceptually, the 'game', isn't it? or am I wrong on this point?

Also, again conceptually, this method is an action (playing the game), thus a verb fits well as a name for it. A function that only computes new data (which is the case for stats) would requires a noun as name, the name of what it computes. But this is all rather personal and you may have a different perspective on all this. (However, this scheme of verbs for actions and nouns for functions works fine, I'm not inventing it; for this reason, I do recommend it as a consistent starting point; then you may later forge your own standard & shortcuts, or adopt the ones of your preferred programming community).

Denis
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to