in reply to Real life OO examples

Most of the modules that look interesting to me wind up looking more complex than I want when I look inside.

OO is a way of simplifying versatilety. So while an OO module may be more complex than its non OO equivelenet, it becomes much easier to extend and the like. A little bit of complexity at the beginning makes the overall project less complex by the end.

For a good example of OO have a look at the File::Spec family of modules. They arent web but they are a good example of practical use of OO.

--- demerphq
my friends call me, usually because I'm late....

Replies are listed 'Best First'.
•Re: Re: Real life OO examples
by merlyn (Sage) on Oct 18, 2002 at 13:58 UTC
    Actually, File::Spec is one of the worst examples in the Perl distro, because it's all about class methods, and no instances, and alters global behavior with global switches instead of carrying differing states around in instance variables.

    For distro-only examples, see the IO::File hierarchy. A little messy, but the inheritance, class, instance, and constructor methods are all pretty interesting and a good use of inheritance (and even dare I say "multiple inheritance").

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

      Oooh. (No pun intended.) Thanks for the clarification. I have to admit that I was thinking mostly on the exposed interface level and didn't consider the innerds at all. Which on reflection upon the OP was reasonably dumb. :-)

      But as a partial justification I was thinking of the way that you have one module with a clearly defined interface, that then automatically uses the appropriate overrides to provide a per OS functionality. While the class based interface is a touch annoying (ive taken to doing

      use constant FS=>'File::Spec'; my ($v,$p,$f)=FS->splitpath($0);
      as a shortcut) the versatility is not.

      Thanks for the pointer though, while not feeling that I need that much extra OO exposure (I do almost pure OO perl, and I've read your and TOMC's and TheDamians books and writings on the subjects already) I will certainly take the time to review these modules to see if theres anything more for me to learn (probably ;-).

      Incidentally, I wonder if pointing out Tie::SecureHash to the OP is worthwhile or not?

      --- demerphq
      Nice disclaimer :-)