Wakane Posted November 12, 2002 Posted November 12, 2002 Hi, All! Before, I've always put my utility subs/functions in a module. for example module "useless" contains one sub Public Sub printHello() MsgBox("Hello") End Sub But since the true classes & OOP are now coming in. I can just put the sub as a shared sub in Useless class. for example class "Useless" contains one sub Public Shared Sub printHello() MsgBox("Hello") End Sub I know there are differences in calling them. One is "printHello()", the other is "Useless.printHello()" But I feel in this particular issue, class is superior, because you can see the grouping (by class name) directly in the code. So something like "StringUtility.ConvertToNumeric("012")" and "DatabaseUtility.GetDatabaseName()" seems to be nicer to read, especially when you've got lots and lots of utility subs/functions. So does it mean that modules are absolete? What are the advantages of using modules than classes in this particular issue (not as the whole, just this issue)? Quote
*Gurus* divil Posted November 12, 2002 *Gurus* Posted November 12, 2002 I don't think there are any advantages in using modules at all. Under the hood, your modules just get compiled as shared methods of classes anyway. I haven't used a module since the first time I broke out VB.NET. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Wakane Posted November 12, 2002 Author Posted November 12, 2002 Thanks I don't think there are any advantages in using modules at all. Under the hood, your modules just get compiled as shared methods of classes anyway. I haven't used a module since the first time I broke out VB.NET. Really? I didn't know that! Thanks. So I think I'll probably go only with classes, because I think it's more organised. :) Quote
wyrd Posted November 12, 2002 Posted November 12, 2002 Modules just give you another way to organize information other then a class. If you don't need to instantiate multiple copies of something then why not just make it a module? It's just there to give you another choice is all. There's also structures now too, which replaced user defined types. Definitely a nice addition but obviously aren't as flexible as a class or module because of restrictions they have. Quote Gamer extraordinaire. Programmer wannabe.
*Gurus* divil Posted November 12, 2002 *Gurus* Posted November 12, 2002 There is really no point in using modules when you could use shared methods of classes instead. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
*Gurus* Derek Stone Posted November 13, 2002 *Gurus* Posted November 13, 2002 Absolutely, divil. Microsoft made two mistakes when they designed .NET: Microsoft.VisualBasic.Compatibility and modules. Quote Posting Guidelines
wyrd Posted November 13, 2002 Posted November 13, 2002 Hmm.. Obviously I still have much to learn about .NET. *zips his mouth and returns to researching* Quote Gamer extraordinaire. Programmer wannabe.
Wakane Posted November 13, 2002 Author Posted November 13, 2002 How about structures? There is really no point in using modules when you could use shared methods of classes instead. Could we say the same regarding the structure and classes relationship? Can a class really replace structure completely (never mind the speed differences for now)? Quote
*Gurus* divil Posted November 13, 2002 *Gurus* Posted November 13, 2002 No, structures and classes are equally useful, they are value and reference types, respectively. Classes derive from MarshalByRefObject, structures do not. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.