in reply to Inheritance and objects tied to a database

First Error: You must inherit new. Otherwise your class isn't tied. Second Error: There is no Parent in perl, it's called SUPER. Turn warnings on and you will see.
  • Comment on Re: Inheritance and objects tied to a database

Replies are listed 'Best First'.
Re: Re: Inheritance and objects tied to a database
by relax99 (Monk) on Dec 20, 2002 at 13:04 UTC

    First: I don't mean to be rude or anything, but let's not pick on words. When we used the word "Parent" here, we meant either using SUPER or writing the specific name of the parent class, which in this particular case would be "Control": $self->Control::DESTROY(). And use strict; use warnings; are implied! If I didn't show them in my code sample, it's only for the purpose of saving space and making it more readable to allow to concentrate on the original problem and not getting side-tracked.

    Second: What's that "must" all about? Are you implying that would solve the original problem? Let's see... the parent class is tied to the database, the child class is tied to the database, child's DESTROY() method is executed first and saves changes to the database, but then parent's DESTROY() method is executed, which overwrites the changes. So, unfortunately "must" doesn't do any good here.

      I think the AM was *trying* to imply that in the code snippet, you've left out the parent's new() call in the child's constructor, so the child never gets tied to the db. Of course, s/he could have just said that :)

      Maybe you could make the child DESTROY method update its parent object's data instead, so only the parent class is allowed to update the db...I suspect you're always going to have problems having multiple objects writing to a db this way unless you get a nice marshalling system going.
      Best o' luck.