in reply to Re: Inheritance and module cross dependencies
in thread Inheritance and module cross dependencies

Thanks.

Now to work out how best to do this without breaking anything...

Prowler
 - Spelling is a demanding task that requies you full attention.

  • Comment on Re^2: Inheritance and module cross dependencies

Replies are listed 'Best First'.
Re^3: Inheritance and module cross dependencies
by gaal (Parson) on Jan 10, 2005 at 07:42 UTC
    Plan:
    1. Create TeacherFactory.pm:

      package TeacherFactory; use Teacher; use strict; sub create_teacher { my ($class, @args) = @_; return Teacher->new(@args); } 1;
    2. Make a list of all files that call Teacher->new.
    3. Insert near their tops a use Teacher; statement.
    4. Search and replace teacher constructions with factory requests.

    That's the easy part; you have a pretty boring factory. Now make it interesting :)

    Most likely, you may find that some calls to Teacher->new give you insufficient information to make the decision about whether a Lecturer or a teacher is required. Refactor your code *after* you have the above in place to either defer or advance the construction, depending on what makes more sense. But move in small steps that don't leave your code unstable.