Login  Register

Re: Package postInstall or Class initializeAfterLoad

Posted by Chris Uppal-3 on Oct 24, 2005; 9:15am
URL: https://forum.world.st/Package-postInstall-or-Class-initializeAfterLoad-tp3375984p3375988.html

TimM wrote:

> What are the pro's and cons of using a postInstall script in the package
> browser or simply implementing an #initializeAfterLoad on a class?

It's more normal to override the class-side #initialize method (there are many
examples in the image).  You /can/ override #initializeAfterLoad if you need
to, but you very rarely need that extra complexity.

There is no defined order in which classes are initialised, so it can sometimes
be awkward to perform some system-wide initialisation from #initialize, since
the participating classes may not all be initialised yet.  There are various
ways around that, one of the simplest is to invoke the global setup from the
post install script.  That way the individual classes can concentrate on
initialising /themselves/, and the final (system-wide) initialisation is
invoked later.

BTW, even in that case, I would put the code for the system-wide initialisation
into a class-side method somewhere, and the post install script would simply
invoke that.  There's no point in putting complex code in a post-install
script.

    -- chris