I find myself writing snippets of code inside other modules and scripts that look like this:
{ # localize $foo
my $foo = 0;
use constant FOO_CYCLE => 23;
sub note_a_foo {
$foo++;
}
sub check_foo {
return unless $foo >= FOO_CYCLE;
$foo = 0;
do_something_about_foo;
}
}
And then elsewhere:
for (long_loop) {
...
note_foo;
...
}
The block localizing the $foo counter isn't really an object; what would you call it? I've got enough of these now in my production code that I'd like to have some term for them, like "nugget" or "black box" or "micro-object", so that my documentation for each can be more immediately meaningful to another reader. Is there a commonly used term for such a construct?
--
Jeff Boes vox 269.226.9550 ext 24
Database Engineer fax 269.349.9076
Nexcerpt, Inc. http://www.nexcerpt.com
...Nexcerpt...Connecting People With Expertise
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|