Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 1
    Perhaps you should think about how you'd like this to look from the outside. cat.attack(dog)? dog.beAttackedBy(cat)? Does it matter what specific attack is being dealt, to either party? Commented Mar 5, 2017 at 16:55
  • @jonrsharpe your point sounds interesting... beingAttackedBy(enemy: Playable) can be nice to avoid having to extend the Attackable interface and implementations each time a new action would be added. What I don't see here is the way to achieve that when someAnimal.beAttackedBy(otherAnimal) happens, the otherAnimal action is performed over someAnimal. Any ideas? Commented Mar 5, 2017 at 17:10
  • 1
    Eric Lippert discusses this at length Commented Jan 30, 2018 at 13:06