Re: Global Functions
Tom Leylan wrote (inline):
I wouldn't go as far as to recommend to *never* use a module. There are
times when the extra syntax needed to create a module-like class just
gets in the way. VB gives you the tools and a Module is just one of
them. Understand it and use it.
Yep, the C# 2.0 folks would do that, allright. They'd say "Look, they
call static classes a 'module'!". =)))
BTW, C++ folks may also be intrigued by why are we using such an arcane
construct, cause 99% of the C++ coders I know write OOP-only code...
oops, sorry, I guess I got these stats reversed.
No arguing about that... =)
One of the ways to provide singleton-like functionality is to hide the
actual singleton inside a, uh, module, and provide only controlled
access to it through the methods of the module. Of course, you may
approach singletons however you like. Unfortunately, IMHO, the
SomeClassWithPr ivateConstructo r.CreateInstanc e() approach to
singletons, besides tasting much like Java, lacks the clarity of the
good old "New Someclass()".
Regards,
Branco.
Tom Leylan wrote (inline):
Anil: Yes you can read it right here :-) Never use a module!
times when the extra syntax needed to create a module-like class just
gets in the way. VB gives you the tools and a Module is just one of
them. Understand it and use it.
VB.Net is an object-oriented language and by definition that should lead to
object-oriented solutions. If there is no OOP solution (and that would seem
unlikely given apps written in SmallTalk, C++, Java, C# and all the other
OOP-based languages) then one might find themselves forced into having to
resort to a "hack". Take my word for it don't start with the "hack" or you
will never stop applying hacks. People will stare at your code and giggle
behind your back...
object-oriented solutions. If there is no OOP solution (and that would seem
unlikely given apps written in SmallTalk, C++, Java, C# and all the other
OOP-based languages) then one might find themselves forced into having to
resort to a "hack". Take my word for it don't start with the "hack" or you
will never stop applying hacks. People will stare at your code and giggle
behind your back...
call static classes a 'module'!". =)))
BTW, C++ folks may also be intrigued by why are we using such an arcane
construct, cause 99% of the C++ coders I know write OOP-only code...
oops, sorry, I guess I got these stats reversed.
What you are describing isn't a "module" you are describing a Singleton
Class. If you want to read something perhaps about the Singleton Class
would be a good start.
Class. If you want to read something perhaps about the Singleton Class
would be a good start.
One of the ways to provide singleton-like functionality is to hide the
actual singleton inside a, uh, module, and provide only controlled
access to it through the methods of the module. Of course, you may
approach singletons however you like. Unfortunately, IMHO, the
SomeClassWithPr ivateConstructo r.CreateInstanc e() approach to
singletons, besides tasting much like Java, lacks the clarity of the
good old "New Someclass()".
Regards,
Branco.
Comment