realbasic-nug
[Top] [All Lists]

Re: Constructors for Modules

To: REALbasic Network Users Group <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Constructors for Modules
From: Robert Steely <robsteely at nc dot rr dot com>
Date: Wed, 30 Jul 2003 19:26:14 -0400
On Wednesday, July 30, 2003, at 01:56  PM, Joseph J. Strout wrote:

Given that modules are not objects but are still logical holders of global
methods and properties, is it technically possible to add
constructor/destructor functionality to initialize properties?

Sure, it's possible. But why? Wouldn't it make more sense to use a class for this sort of thing?

Because a class is useless by itself; you have to have an object. Sometimes a Singleton object is the right approach, but often not -- and even when it is, in RB, you would need a module to manage your singleton instance. That's a nuisance.

I have a lot of modules with an Init method, which I have to be sure to call at the beginning of my app. I can certainly see the value in having that method called automatically by the compiler at app startup. (And perhaps another one called when the app is exiting, too.)

I also commonly use modules that must be initialized from the App.Open event. Module constructors and destructors would definitely come in handy.

I signed on to:

http://support.realsoftware.com/feedback/ viewreport.php?reportid=oegkdhjs

Bob


---
A searchable archive of this list is available at:
<http://support.realsoftware.com/listarchives/search.php>

Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>
.


<Prev in Thread] Current Thread [Next in Thread>