Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In Perl, </p> <ul> <li><p>make it required that <code>use strict</code> and <code>use warnings</code> are on in 100% of the code</p></li> <li><p><strong>You can try to make an almost private member variables by creating <a href="http://perldoc.perl.org/perlfaq7.html#What%27s-a-closure?" rel="nofollow noreferrer">closures</a></strong>. A very good example is "Private Member Variables, Sort of " section in <a href="http://www.usenix.org/publications/login/1998-10/perl.html" rel="nofollow noreferrer">http://www.usenix.org/publications/login/1998-10/perl.html</a> . They are not 100% private but fairly un-obvious how to access unless you really know what you're doing (and require them to read your code and do research to find out how).</p></li> <li><p>If you don't want to use closures, the following approach works somewhat well:</p> <p>Make all of your object member variables (aka object hash keys in Perl) wrapped in accessors. There are ways to do this efficiently from coding standards POV. One of the least safe is Class::Accessor::Fast. I'm sure Moose has better ways but I'm not that familiar with Moose. </p> <p>Make sure to "hide" actual member variables in private-convention names, e.g. <code>$object-&gt;{'__private__var1'}</code> would be the member variable, and <code>$object-&gt;var1()</code> would be a getter/setter accessor.</p> <p>NOTE: For the last, Class::Accessor::Fast is bad since its member variables share names with accessors. But you can have very easy builders that work just like Class::Accessor::Fast and create key values such as $obj->{'__private__foo'} for "foo".</p> <p>This won't prevent them shooting themselves in the foot, but WILL make it a lot harder to do so.</p> <p>In your case, if they use <code>$obj-&gt;goo</code> or <code>$obj-&gt;goo()</code>, they WOULD get a runtime error, at least in Perl.</p> <p>They could of course go out of their way to do <code>$obj-&gt;{'__private__goo'}</code>, but if they do the gonzo cowboy crap due to sheer laziness, the latter is a lot more work than doing the correct <code>$obj-&gt;foo()</code>.</p> <p>You can also have a scan of code-base which detects <code>$object-&gt;{"_</code> type strings, though from your description that might not work as a deterrent that much.</p></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload