Skip to content

Instantly share code, notes, and snippets.

@masak

masak/reply.txt Secret

Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masak/a788a742b70c47e46565 to your computer and use it in GitHub Desktop.
Save masak/a788a742b70c47e46565 to your computer and use it in GitHub Desktop.
Reply to Henk about teaching newbies
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.
@perlpilot
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment