On 19 Jul 2013, at 16:52, Graham Ashton <gra...@effectif.com> wrote:

> Imagine how you'd feel digging into somebody else's code, investigating some 
> bug or other, to find that they'd overridden `#send`. Now see if you can get 
> a handle on how you'd feel when realising that they'd used it for a different 
> purpose than it was originally intended.

Well, I considered this, but it didn't seem such a big risk. I tried to imagine 
a scenario where somebody would be metaprogramming against my message bus 
(which would have a publicly documented #send). Given it only responds to 
#register, #send and #publish, and you'd normally use it like this:

    bus.register(:turn_on_kettle, kitchen_handler)
    …
    bus.send(:turn_on_kettle)

 I was struggling to picture code like this:

    abstract_trasport_thingy.send(messaging_method_name, *args)

Which would actually blow up immediately as the bus tries to extract a 
message_type from the first argument.

Interestingly the internals of the bus *do* use metaprogramming, because they 
unpack the message and send :handle_<some_message_type> (eg 
:handle_turn_on_kettle) to the registered handlers. So in a sense it's acting 
as a networking switch, translating messages down to a lower level messaging 
system.

> Hope that helps.
> 
> If you're still unsure, my initial thought as I started reading your email's 
> subject was "jesus no!!!" ;-)

Well, abstract horror is always worth taking into account :)

> How about `#tell`?

I'm struggling to form a sentence with it. "Bus, send this message" sounds more 
natural to me than, "Bus, tell this message"

Cheers
Ash


-- 
http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashmoran

-- 
You received this message because you are subscribed to the Google Groups 
"NWRUG" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nwrug-members+unsubscr...@googlegroups.com.
To post to this group, send email to nwrug-members@googlegroups.com.
Visit this group at http://groups.google.com/group/nwrug-members.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to