(resending to p6u)

Tom (>>), Henk (>):
> > That doesn't seem to work with private methods.  Any trick to accomplish 
> > that?
>
> What part of 'private' did you mis?

Henk, that's an unnecessarily harsh way to say "Private methods are
private and not visible or testable outside of the class."

In my copious spare $dayjob, I teach. Any kind of teaching seems to
involve taking both the teacher's stance (of knowing stuff and being
able to phrase it right) and the learner's stance (trying to remember
what it was like *not* to know something). Pulling that off, and being
able to speedily convey people along all intermediate points from
not-knowing to knowing, is a weirdly satisfying experience.

Questioning the querent's knowledge sends the message (to the querent
and to passive beginner onlookers) that it's somehow a bad idea to ask
direct questions. It's also a non-constructive response, putting the
focus on how much someone knows or doesn't know, rather than the
subject matter. The querent responded very well in this case ("I think
I need to learn a lot more about testing in general."), but lesser
provocations than yours have led to flame wars online.

(A) "Private methods are private and not visible or testable outside
of the class." is only the most proximal answer to the question.
There's also (B) "You can do most things using the MOP, including
finding private methods." (Pointed out by moritz++.)

    $ perl6 -e 'class C { method !foo {} }; say C.^find_private_method("foo")'
    foo

Or how about (C) "The underlying reason we only test on the public
interface is so that the internal bits of an object can change freely
without breaking the test." as a response? Or maybe even (D) "There
are ways to test just on the *consequences* of a (public)
message-send, such that you don't even *want* to introspect the
private parts." (Which leads to a more BDD-y style of testing.) Either
of these answers helps convey the querent to a better understanding.

Teaching is about compassion. Literally "feeling with" the querent. If
you find yourself unable to do that when replying, consider whether
you're simply having a bad day. If the problem persists, ask yourself
whether your reply is representative of the people on p6u who enjoy
helping scurry people forwards along the learning curve.

// Carl

Reply via email to