realbasic-betas.mbox
[Top] [All Lists]

Re: OT: Global Methods

To: REALbasic Betas <realbasic-betas at lists dot realsoftware dot com>
Subject: Re: OT: Global Methods
From: Robert Steely <robsteely at nc dot rr dot com>
Date: Fri, 25 Oct 2002 18:14:53 -0400
On Friday, October 25, 2002, at 05:34  PM, TM Lutas wrote:

This seems to be going one way. Is there any reason not to put something in a module?

Encapsulation. Placing application-specific, non-reusable code in the Application class is more OOP than using modules. Methods and properties of the Application class exist in their own namespace reducing the chances of name conflicts.

On the other hand, modules come in handy when you want to create libraries of common functions that you will use in many programs. For instance, I have a module containing often-used string handling functions and another for file handling. Modules are also important if you want to define global constants. (I don't like defining constants in properties because it introduces the possibility of inadvertently changing the value, thus producing a hard-to-find bug.) Methods executed from modules also tend to be slightly faster than those in classes, but this is only apparent when calling functions many thousands of times. And the execution speed is also affected by where you call the function from so, your mileage may vary.

Bob


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

Unsubscribe:
<mailto:realbasic-betas-off at lists dot realsoftware dot com>

Subscribe to the digest:
<mailto:realbasic-betas-digest at lists dot realsoftware dot com>
.


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