Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5997735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:18:22+00:00 2026-05-23T00:18:22+00:00

During the design of a new application I was wondering if using a module

  • 0

During the design of a new application I was wondering if using a module with properties is considered to be a bad practice.

Some example code:

Module modSettings

   public property Setting1 as string

   public property DatabaseObject as IDatabaseObject

End Module

The code above is just an example to emphasize my question. In the past, this structure was used a lot in VB6. In the past I used it as well in my .NET projects.

But nowadays with buzzwords like Dependency Injection, Testability and Separation of Concerns the above structure smells bad. I can’t really describe why, but it just feels wrong. I must admit I’m not very familiar with the keywords above, yet.

So I’m wondering whether the above code really is a bad practice. If so, what would you use a Module for?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:18:23+00:00Added an answer on May 23, 2026 at 12:18 am

    Centro is right that a Module (or a NotInheritable Class with Shared members) is the closest equivalent to a C# static class. So technically, nothing is wrong with it as it’s just one of VB’s ways of creating this type of class. For example, you cannot say Public Shared Class Settings in VB as you cannot put the Shared keyword on a class.

    On its own I wouldn’t call it bad practice if a specific circumstance calls for a Module, but otherwise a Module (or other static class equivalents) likely is not the design choice you want for having loosely coupled, testable code. Additionally, while a NotInheritable Class with Shared members is more descriptive than just saying Module, there is at least one circumstance where a Module must be used instead.

    When would you need to use Modules in VB.Net? If you want to take advantage of extension methods, then it’s your only option since as mentioned, you cannot create a shared (static) class in VB.Net, neither can you use extensions on NotInheritable Classes. You must use a module as follows:

    Imports System.Runtime.CompilerServices
    
    Public Module StringExtensions
        <Extension()> _
        Public Function Remove( _
                            ByVal input As String, _
                            ByVal subStrings As String()) As String
            Return String.Join("", input.Split(subStrings, StringSplitOptions.None)).Trim()
        End Function
    End Module
    

    In C# you can’t use modules and must use static classes as follows:

    public static class StringExtensions
    {
        public string Remove(this string input, string[] subStrings)
        {
            return string.Join("", input.Split(subStrings, StringSplitOptions.None)).Trim();
        }
    }   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

During the design of a new generic authentication framework for some of our products,
During the Compiler Design Lab hours, I'm using JLex as the Lexical Analyzer Generator,
We need to generate LINQ queries which are 100% unknown during coding (design time).
During my apprenticeship, I have used NHibernate for some smaller projects which I mostly
During execution, how can a java program tell how much memory it is using?
In some of my application designs or for just some UIViews, following a navigationController's
If I don't know what htmlhelper I want to use during design time.., Then
Is it bad practice to have placeholder data in your source control repository? For
I have to design and develop a data driven application from scratch to administer
I'm new to Maven. I have a multi-module maven 2 project that has the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.