The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>OVERWRITTEN CODE</title>
<link rev="made" href="mailto:juguang@commandos.local." />
</head>

<body style="background-color: white">

<p><a name="__index__"></a></p>
<!-- INDEX BEGIN -->

<ul>

	<li><a href="#overwritten_code">OVERWRITTEN CODE</a></li>
	<ul>

		<li><a href="#terminology">Terminology</a></li>
	</ul>

	<li><a href="#blackbox_v.s._whitebox_overwritting">Black-box v.s. White-box overwritting</a></li>
	<li><a href="#how_autocode_tries_to_avoid_or_intend_to_overwrite_the_method">How AutoCode tries to avoid or intend to overwrite the method?</a></li>
	<ul>

		<li><a href="#principle">Principle</a></li>
		<li><a href="#solution_1">Solution 1</a></li>
		<li><a href="#solution_2">Solution 2</a></li>
	</ul>

	<li><a href="#am">AM</a></li>
</ul>
<!-- INDEX END -->

<hr />
<p>
</p>
<h1><a name="overwritten_code">OVERWRITTEN CODE</a></h1>
<p>How to make the same method with different code?</p>
<p>It sounds weird for normal programmer, who never hacks the Perl and does the 
regular job.</p>
<p>Before this auto code generators appear, there is already such problem that one 
methods in a Perl module can be overwritten.</p>
<p>
</p>
<h2><a name="terminology">Terminology</a></h2>
<p>CG - Code Generator</p>
<p>AM = AccessorMaker</p>
<p>
</p>
<hr />
<h1><a name="blackbox_v.s._whitebox_overwritting">Black-box v.s. White-box overwritting</a></h1>
<ul>
<li><strong><a name="item_black%2dbox">Black-box</a></strong><br />
</li>
The code is known neither on what the code inside is, nor what it does at all.
<p></p>
<li><strong><a name="item_gray%2dbox">Gray-box</a></strong><br />
</li>
Parially the function of the code is known, but the implementation of it remains concealed.
<p></p>
<li><strong><a name="item_white%2dbox">White-box</a></strong><br />
</li>
The implementation of it can be detected by human or other code.
<p></p></ul>
<p>
</p>
<hr />
<h1><a name="how_autocode_tries_to_avoid_or_intend_to_overwrite_the_method">How AutoCode tries to avoid or intend to overwrite the method?</a></h1>
<p>
</p>
<h2><a name="principle">Principle</a></h2>
<p>Supposed the user understands what AM does.
The priority of user's code is always higher than the one generated by AM.</p>
<p>CG may never overwrite the existing code, while user's code may overwrite
CG'ed code.</p>
<p>Can we do anything to avoid user overwrite CG's code?</p>
<p>Potentially, other CG may overwrite the existing code, even the user written ones.</p>
<p>Users are suggested to overwrite AM generated code by subclassing the class
and override them.</p>
<p>
</p>
<h2><a name="solution_1">Solution 1</a></h2>
<p>In AM, there is a %MADE_ACCESSORS hash with keys as the fully qualified method
names and keys as whatever non-zero values.</p>
<pre>
    $MADE_ACCESSORS{$glob}=1;</pre>
<p>
</p>
<h2><a name="solution_2">Solution 2</a></h2>
<p>The assisted modeul/class, CG addes a %MADE_BY for each of them.</p>
<pre>
    $MADE_BY{$method_name}='AM';</pre>
<p>
</p>
<hr />
<h1><a name="am">AM</a></h1>
<p>AM is the lowest level CG.</p>

</body>

</html>