Advertisement
Guest User

Untitled

a guest
Jan 17th, 2012
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. Tony's response:
  2. Your solution adds a dependency from limb -> person where his has the dependency from person -> limb. It's really the same amount of coupling but my gut says it'd be better to have person -> limb. The limb belongs_to person relationship isn't really even necessary, just kind of convenient. You're solution also requires an individual limb to be aware of the other limbs on the creature, which is undesirable.
  3.  
  4. If you wanna go crazy flexible you abstract limb to an appendage interface and person to an appendgeContainer (or some better name) interface. Then person implements IAppendageContainer which demands a validateAppendages() method that acts on a list of appendages. Shit, even limb could then have appendages and HumanArm (implementing IAppendageContainer) could validate that it has one hand and HumanHand could validate that it has 5 fingers. Point is, probably makes sense to have validation on the appendage-holder rather than the appendage itself.
  5.  
  6. But, that's certainly more than this guy needs and is over-engineering. In the end, there's not much difference between the two and he has to go with what makes sense to him.
  7.  
  8. A few minutes later from Tony:
  9. After my brain chewed through that a bit more i think that "you're solution also requires an individual limb to be aware of the other limbs on the creature" is the only real flaw. Consider improving the validation to make sure that a Person has 2 arms and 2 legs. Would you want the Leg class to have to do that? The Arm? It really only makes sense for the person to validate their own limbs. If the limb does it, what happens when you implement a Quadriplegic?
  10.  
  11.  
  12.  
  13. Lee Quarella: isn't that taken care of with
  14. self.creature.limbs.length <= self.creature.min_limbs
  15.  
  16. Tony: not when the type of limb matters
  17. Tony: how 'bout peg-legged pirate
  18. Tony: he needs one peg-leg, one real leg, and two arms, one of which has a hook for a hand
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement