OVERWRITTEN CODE

How to make the same method with different code?

It sounds weird for normal programmer, who never hacks the Perl and does the regular job.

Before this auto code generators appear, there is already such problem that one methods in a Perl module can be overwritten.

Terminology

CG - Code Generator

AM = AccessorMaker


Black-box v.s. White-box overwritting


How AutoCode tries to avoid or intend to overwrite the method?

Principle

Supposed the user understands what AM does. The priority of user's code is always higher than the one generated by AM.

CG may never overwrite the existing code, while user's code may overwrite CG'ed code.

Can we do anything to avoid user overwrite CG's code?

Potentially, other CG may overwrite the existing code, even the user written ones.

Users are suggested to overwrite AM generated code by subclassing the class and override them.

Solution 1

In AM, there is a %MADE_ACCESSORS hash with keys as the fully qualified method names and keys as whatever non-zero values.

    $MADE_ACCESSORS{$glob}=1;

Solution 2

The assisted modeul/class, CG addes a %MADE_BY for each of them.

    $MADE_BY{$method_name}='AM';


AM

AM is the lowest level CG.