ralph
8/3/2011 2:28:00 PM
On Tue, 02 Aug 2011 18:58:46 +0100, MM <kylix_is@yahoo.co.uk> wrote:
>On Tue, 2 Aug 2011 12:57:08 -0400, "Jim Mack" <no-uce-ube@mdxi.com>
>wrote:
>
>>MM wrote:
>>> Given that I have a user-defined type declared in a .bas module, is
>>> it better to have
>>>
>>> Public MyUDT As MyType in the module
>>>
>>> or
>>>
>>> Private MyUDT As MyType in a form?
>>>
>>> The MyUDT is only referenced in the form.
>>>
>>> I've tried both and there appears to be no difference.
>>
>>It may make a difference if you intend to use tlbinf32.dll. Private
>>objects are not part of the public contract.
>
>But from a 'purist' POV, is there any ~convention~? Isn't it better to
>assign variables as little scope as possible? I'm trying to think
>'classy' here (!) and not modular.
>
>What gave me the idea to move the declaration to the form was that it
>was nonsensical calling the QuickSort proc and passing the UDT array
>when this was global. (The QuickSort proc resides in a module, along
>with other 'helper' procs/functions.)
>
This too has been beaten to death, if you have several UDTs that are a
critical part of your Application it is best to create a project type
library and declare them there. For a one-time store, probably not. (I
do it for All UDTs, but that"s just me. <g>)
UDTs usually package something of business interest and these things
have a habit of multiplying or rather expanding outside the initial
design, or to other projects/components. Having a single 'spot' of
declaration that can be used in any context is useful.
Once declared in a Type Library you can set it and forget it.
-ralph