class Post
def created
user.post_created(self)
end
def send_to_feed(feed)
feed.send(contents)
end
end
class TwitterUser
def post_created(post)
post.send_to_feed(twitter)
end
end
class EmailUser
def post_created(post)
# no-op.
end
end
The post merely tells its user that it was created. Then the user can decide to do something else. All users know about posts, but only TwitterUser knows about feeds.Honestly though, if I saw the not-so-good code, I'd leave it alone. It takes a pretty big justification to double the code for the same features.