To organize communication between entities that don't know each other
Objects communicate by sending and receiving messages
bob = Bob.new
bob.fat?codetunes.subscribe(alice)
codetunes.subscribe(bob)
codetunes.release_post(post)
class Codetunes
def initialize
@subscribers = []
end
def subscribe(subscriber)
@subscribers << subscriber
end
def release_post(post)
# ...
subscribers.each do |subscriber|
subscriber
.read_codetunes_post(post)
end
end
endsea = Sea.new
robinson.throw_buttle(target: sea)
alice.watch(sea) do |finding|
if finding.respond_to?(:message_in_bottle)
alice.decipher_message_in_bottle(finding)
end
end