in reply to Re: Re: Parsing conditional expressions
in thread Parsing conditional expressions

Create a class called Packet and subclasses called Packet::TypeA, Packet::TypeB, etc. Then, using a factory, create the appropriate subclass. Have each subclass know how to validate itself. No need for eval.

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

Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

  • Comment on Re: Re: Re: Parsing conditional expressions

Replies are listed 'Best First'.
Re: Re: Re: Re: Parsing conditional expressions
by Lorand (Beadle) on Mar 23, 2004 at 18:07 UTC
    OK, I didn't think of this, it seems to be the best solution, however I don't know what a factory is, and couldn't find anything that would make that clear... Could you point me to some relevant documentation, maybe a place with examples?
      A factory is a class or object that creates objects. It's a design pattern. Try googling for "object factory design pattern perl". The first several links look good.

      The basic concept is that you ask the factory for an object given a set of parameters and it returns back an object of the appropriate class(es), if possible.

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

      Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose