Tom Leylan wrote (inline):
I will suggest it is "easy" but I'm doubtful that it is the "standard" or
(if it is at this point) that it will remain so.
http://msdn2.microsoft.com/en-us/library/7825002w(VS.80).aspx
I don't see in the article linked above nothing that recomends not
using modules or suggests that modules will be removed from the
language, as your phrasing seems to imply...
I'd like to caution the OP against modules. As the number of public
functions increases you'll tend to want to organize them in some way,
classes do this for you in a natural way.
Well, while this is true (the complexity growth of a program to the
point the programmer wanting to reorganize it, specially in the
presence of public functions), it doesn't seem to be an impediment to
using modules, I guess.
Sometimes, as the code evolves, I see the need to reorganize entire
classes: break them up, remove functionality, encapsulate things more
tightly, change accessibility of things, you name it. Interestlingly,
this happens much less with modules, because -- and this is just my
personal experience, mind you -- whenever I create a global method in
a module, the scope of the method seemed global to me right from the
start, and this "notion" of globality hardly changes throughout the
development proccess.
Perhaps as an exercise you could list (here) the names of 3 or 4 functions
which you might consider putting into a module. What are their names and
(if isn't obvious) what do they do?
<snip>
One of the first things I do when creating a new application is to
create a Test module, with methods that I can call from the immediate
window. While I could easily declare an abstract class for this, say a
Public NotInheritable Class Test, filled with shared methods, I don't
see the need: I'd be just duplicating -- and complicating -- the
functionality that modules provide.
As for the names of methods, it really depends on the nature of the
module -- yes, you can have more than one, and yes, you can use their
names as a way of organizing things, I guess you already knew that,
but, since you don't use modules at all, I thought it was worth
remarking. As I was saying, it would really depends on the nature of
the module, what global encapsulation it was meant to achieve.
But then, again, it's just a language feature, use it if you want.
What I don't really agree is a recomendation against its use without
some serious evidence that the feature is bad practice/a detriment of
readability/alien to the language/source of bugs/whatever...
Your argument against modules, as far as I've seen, is "don't use
modules because":
a) other languages don't use them -- which is simply not true; some
languages do have something similar to modules, such as C# (static
classes), Delphi (elements declared in the public interface of units),
C++ (elements declared in the global namespace), Python (ditto), and
the list goes on;
b) they're a legacy from the past. Well, what isn't? This is an
evolution/rewriting/addaptation/whatever of a previously existing
language, a few things were lost in the process, others were added,
others remained for compatibility purposes, and others were kept I
guess because they were just part of the language's identity. Now, for
the things that were kept for compatibility sake, there's always a
warning in the documentation and a recomendation of the correct way of
doing it in new code -- I don't see so for modules (maybe this is a
hint that modules were not left in the language just because of
compatibility with previous code);
c) Non-Vb coders will find it hard to understand their implication...
Well, I'm not a Java programmer and had a hard time understanding
inner classes, or "public static final" elements (aka consts). Guess
the creators of the language didn't have your consulting when they
created such elements, huh?
I'm not a Lisp programmer either, and I find this talking about "car",
"cdr" and "lambda" a complete mistery -- why these folks couldn't use
more mundane terms I ask you.
I *am* a Delphi programmer (at least I used to be) and to this day I'm
baffled by the rules of block declaration and the -- unique! -- use of
the ";" separator in certain contexts -- switch blocks and If...
then ... else blocks, just to name some.
I *am* a PHP programmer (now and then, I must say) and when reading
someone else's code I wonder whether it's assuming "register_globals"
or "magic_quotes_gpc" on or off, because it isn't stated anywhere. How
evident would this be for a non-PHP programmer (considering the impact
such settings have in the resulting computation)?
And the list could go on.
Long remark short, the allegation that modules are not "recognizable"
by coders of other languages is, I'm sorry to say, almost laughable,
please, don't make that claim again in public places, its forced
reasoning doesn't fit in the quality of your other posts (which, for
the records, I personally really enjoy).
d) "I personally don't see their need" -- well, you're entitled not
to, but that doesn't really make it a compelling argument;
d) "I'll fire you if you use them" -- now, *THAT* would be a good
argument, but only if you were talking to one of your employees, which
is not the case of the OP, I guess, or the majority of the readers of
the list... =))
Regards,
Branco.