Hacker News new | ask | show | jobs
by abecedarius 4879 days ago
OOP goes bad when you take a centralized design and nominalize the verbs, yes. It's more fun to think in terms of trained animals: "Trash, go empty yourself outside."

    TrashBag >> emptyInto: vessel
      |here| here := self place.
      self go: vessel place.
      vessel add: self spill.
      self go: here
This seems just as reasonable as the English he wrote. (I like functional programming too.)
1 comments

Trained animals is a good metaphor. Not passive objects acted upon but actors. Your example is even cleaner in Self which allows implicit 'self':

  emptyInto: vessel = (| here |
    here: place.
    go: vessel place.
    vessel add: spill.
    go: here
  )