On 2009-11-16, Marnen Laibow-Koser <marnen / marnen.org> wrote: > a = Stat.new(5) > b = Stat.new(5) > > Should a == b return true or false? > If false, then this is probably not a value object in the conventional > sense. > If true, then it probably is. Hmm. I would think it should return true. > Poor analogy. I think your paycheck is like your character's entire > stat block, whereas the individual Stat objects seem to be analogous to > the dollar amounts on each like of the paycheck -- and those are > certainly value objects. An individual stat might have: base value 10 modifier (racial, no duration) +3 modifier (training, no duration) +2 modifier (drunk, duration 15 turns) -1 That's "a 14". It is *equal to* another stat which has a base value of 14 and no modifiers. But it's not the same *thing* as that other stat. > And I think you're probably wrong. > > john = Character.new > john.strength = Stat.new(15) > mary = Character.new > mary.strength = john.strength > mary.strength += 1 > > Now, what should john.strength be? 15 or 16? 15. But you don't copy stats -- you use their values. So what really happens is that mary defines strength= such that it applies modifiers to mary.strength. In fact, in "john.strength = Stat.new(15)", what really happens is that john does the same thing -- adjust the already-existing stat so that it will have an effective value of 15. Hmm. So, thinking about it, it seems like what I'm getting to is that really, the "Stat" class is largely internal to characters. It's a way to express something that, in general, no one else should use. (Not quite true; you can query the modifiers that currently apply to a stat, for instance.) For the purposes of nearly any possible interaction, john.strength is just the value 15. You're asking some really good questions here, thanks. -s -- Copyright 2009, all wrongs reversed. Peter Seebach / usenet-nospam / seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!