in reply to Re^3: (How) Do you document/test your private subroutines?
in thread (How) Do you document/test your private subroutines?

> But I sure don't want to override any of them accidentally

underscore _convention() ?

> That alone should warrant making anything you truly need to be private into a coderef.

But coderefs can't be used for protected routines.

Anyway, I have no issues with documenting private routines, as long as it's clear they are not part of the compatibility "contract".

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

  • Comment on Re^4: (How) Do you document/test your private subroutines?

Replies are listed 'Best First'.
Re^5: (How) Do you document/test your private subroutines?
by choroba (Cardinal) on Nov 12, 2018 at 16:56 UTC
    > underscore _convention()

    That's the problem. If the parent class defines _frobnicate but doesn't document it, you might accidentally define _frobnicate in the child class (because underscore convention!) to do something completely different, and kaboom!

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

      Or worse still, you're writing a child class and carefully check that the parent class doesn't define _frobnicate; everything seems good. Then you install an upgrade of the parent class from CPAN, and it defines _frobnicate.

      If the updated parent class had made frobnicate a public method then the problem would be pretty easy to track down, maybe even by just reading the Changes file. If the updated parent class had used my $_frobnicate = sub { ... }; this wouldn't be a problem to begin with.

      > you might accidentally define _frobnicate in the child class ... and kaboom!

      for completeness, we might not get a "Subroutine _frobnicate redefined at" warning but it is possible to dynamically inspect a parent class with ->can from UNIVERSAL

      So it's not that the "sub-class"-developer is completely in the dark.

      It should even be possible to check this automatically.

      (which is the saner approach since people don't tend to read the docs after a parent class got extended)

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      ahh ... I see.

      I think we have now three documentation levels to be distinguished:

      • docs for the user of the module/class
      • docs for the developer of subclasses
      • docs for the maintainer

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice