in reply to Re^3: OO-Perl Question: How Do I get a List of derived Classes for a Base Class?
in thread OO-Perl Question: How Do I get a List of derived Classes for a Base Class?

All that knowing what is available achieves, is the ability to take a slightly earlier exit
I think there is more than that to it.

How would the main loop know how to parse the SQL for "new" types of comments? Probably (really just a guess) the sub-classes provide a method that returns a regex which can be used to parse the SQL and check for that specific type of comment. Adding another sub-class and going through the list of sub-classes would make that method available without having to hard-code it into the main loop.

Of course that still leaves you the task to use or require all the sub-classes in some automated way.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^5: OO-Perl Question: How Do I get a List of derived Classes for a Base Class?
by BrowserUk (Patriarch) on Mar 14, 2010 at 19:41 UTC
    How would the main loop know how to parse the SQL for "new" types of comments?

    It's not that hard to see a comment format/regex combination that allows for that.

    A regex of m[-- class:(\w+)] for instance would pick out a class name that can be combined with some root to require and instantiate the appropriate subclass if available.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.