2

I have started learning VB.NET lately and have read 1 Step-By-Step beginners book and am now moving onto an Advanced book and both have failed to really explain what the point in modules and classes are.

Are modules and classes simply ways to organize functions and sub-procedures?

E.g. A class named MyMathClass which contains 100 different Math functions would be easier to skim through compared to a file with 100 non-related functions.

2
  • Don't mix-up classes with a collection of functions. I fear that the books haven't only failed in explaining what modules are but - much more important - what classes and objects are in an object-oriented context. Commented Aug 22, 2011 at 22:28
  • Here are more informations on OOP in .NET. By the way, a module really is like a collection of functions for a speific context(f.e. Math-Algorithms). But i would avoid Modules at the first place because they prevent understanding the OOP-concepts since there is no (public) constructor and all functions/properties are shared. Commented Aug 22, 2011 at 22:37

2 Answers 2

4

Modules are a VB6 left-over. Required for compatibility, there's little point in using them when you program from scratch. Biggest problem with them is that they pollute the global namespace. That might be nice at first but it scales very poorly. They are however still used to create extension methods, adding those to the global namespace is the intended effect.

Grokking classes requires understanding Object Oriented Programming. That cannot reasonably fit in an SO post, there are many introductory books that help you in the grok.

Sign up to request clarification or add additional context in comments.

1 Comment

Modules are the equivalent of C# static classes and the only way to write extension methods in VB, so they do have uses for new programs still.
0

I would agree with Tim Schmelter. While there still are uses for modules for extension methods, since you are learning OOP principles, stick to using classes. With classes, you can really take advantage of the 3 pillars of OOP (Encapsulation, Inheritance, and Polymorphism) without thinking about modules which can add to confusion at this stage of learning.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.