Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Keep in mind that I only get to read what you post, and the general uselessness of "Can't you just..." [].

    A couple of people have already mentioned Memoize, which return the same result given the same input. The same result can be the same object. A given company (or whatever the appropriate thing), you can return the same object. This has shades of the Flyweight Design Pattern (note: this is not the same "flyweight" concept that Damian discusses in his book). Keep a collection (the flyweight pool) of objects around the represent an entity. Several other objects can share these flyweight objects.

    The objects are called "flyweight" because they represent little bits of data---a name, or address, and so on---that you use over and over again. The actual data only lives in one place, so you do not have an explosion of identical objects.

    Of course, the point of a design pattern is that you do not need to implement it in any particular way. Once you lookup a company, you could put its data into the hash. No need for fancy classes or objects like you might see in the C++ or Java discussions of these things.