in reply to Re: Re: Re: Re: The costs of packages
in thread The costs of packages

Here is an example written using Class::Factory .

In my factory (Audio::Info), I register all available types (look for register_factory_type, Audio::Info::Ogg and Audio::Info::MP3 for now) upon compilation, and each type is loaded upon first use (I could've done add_factory_type instead, which would load each available type upon compilation of Audio::Info).

I hope that demonstrates it well enough.

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

  • Comment on Re: Re: Re: Re: Re: The costs of packages

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: The costs of packages
by BrowserUk (Patriarch) on Sep 16, 2003 at 20:31 UTC

    Thanks for the examples PodMaster.

    I *think* that the problem with this (for my application) is that it requires that each of the subtypes exist as seperate files? As I (belatedly) outlined elsewhere, the application requires that the packages be generated on demand (from information stored in the top level package, which itself is autogenerated from a set of large C header files). It would be possible to generate the hundreds of small .PM files directly, but the volume would make this messy and difficult to manage.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
    If I understand your problem, I can solve it! Of course, the same can be said for you.

      the volume would make this messy and difficult to manage.

      This is a Straw Man, BrowserUk. At a previous job, I managed over 10,000 (initially) auto-generated classes using two scripts. It's easy, once you have the system in place. (Putting the system in place is often worth the 2-3 days it takes to get right.) Plus, I believe a responder to the initial post pointed out a CPAN solution that might get 90% of the way there ....

      ------
      We are the carpenters and bricklayers of the Information Age.

      The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

      Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

        Hmm.

        Each module consists of only the constructor. Everything else is handled by the superclass.

        If I can have one module that consists of (currently, though it's not finished) around 100 lines of executable code, and one line of data for each of the several hundred types involved, versus one superclass of 100 hundred lines and an 8 line module for each of the several hundred types, I prefer the former to the latter.

        Further more, the data lines are extracted from header files using another script. The header files are subject to changes. These are infrequent, but I'd rather just re-generate the DATA section of one module when required than fuss with maintaining several hundred, small and essentially identical modules.

        I did look at several possible candidates for doing this before I started including Class:Struct , Inline::Struct, C::Dynalib::Struct and Win32::API::Struct, but felt that none of them met my requirements for

        • Ease-of-use (of the resultant types rather than developing my module).
        • Efficiency. Both from the memory and performance stand point and also the effort required on behalf of the user coder.
        • Ease of (re-) generation.

        Basically I thought I could do better, and I do not have the commercial pressures upon me to do it in any give time frame, so I am going ahead with my design. Whether the result will meet my own requiements will take a few more days to verify.

        Whether others will consider my efforts worthwhile I won't know unless I publish the code...which I may do if I am satisfied with the result.

        I really tried to avoid this whole discussion by asking a very specific question. It's difficult to argue the merits for or against what I'm doing without getting into a full blown description of the entire project, which I'm not in a position to do right now.

        When the project is completed, I might work up a comparison between my solution and one or two of the other possibilities suggested and throw it out for discussion. It might be interesting thing to do if anyone else would be interested.


        Examine what is said, not who speaks.
        "Efficiency is intelligent laziness." -David Dunham
        "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
        If I understand your problem, I can solve it! Of course, the same can be said for you.