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 6725471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:48:41+00:00 2026-05-26T09:48:41+00:00

Aside from what is so bad about singletons :-), I have an ASP.NET web

  • 0

Aside from “what is so bad about singletons” :-), I have an ASP.NET web application that utilises singletons at the business logic layer, thus:

public class MyBusinessService
{
    private static MyBusinessService mInstance = null;

    public static MyBusinessService Instance
    {
        get { return mInstance; }
    }

    static MyBusinessService()
    {
        mInstance = new MyBusinessService();
    }
}

We use them primarily for a dependency in a Model View Presenter architecture.

They can also be used across business logic classes in one of two ways. Firstly in the following manner:

var myService = new MyBusinessService();
myService.DoSomething();
myService.DoSomethingElse();

Or, it can be used in the following manner:

MyBusinessService.Instance.DoSomething();
MyBusinessService.Instance.DoSomethingElse();

Which construct is preferred and why? I’m not interested in whether the singleton pattern itself is good or bad.

Update:
Ok, this question seems to be quite popular. I guess it is a quasi-singleton. Worst of both worlds! I’m not really interested in refactoring the pattern / anti-pattern / code hell. I’m more interested in understanding the effects of both usages described.

Our view (ASP.NET page) looks like this:

var presenter = new SomeViewPresenter(this, MyBusinessService.Instance);

but could alternatively be implemented as:

var presenter = new SomeViewPresenter(this, new MyBusinessService());

I prefer the former in this case. N.B. The use of the word singleton and the incorrect usage above is understood, but as the code stands, what is the outcome of the two original options?

  • 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-26T09:48:41+00:00Added an answer on May 26, 2026 at 9:48 am

    The latter is preferred because the former isn’t behaving like a singleton – you are instantiating a new instance without any guards for stopping more than one instance existing.

    The latter is the code you’d likely end up with if you put these guards in place. You don’t need to use the property all the time too:

    var service = MyBusinessService.Instance;
    service.This();
    service.That();
    

    I also look at statics in ASP.NET with some skepticism and this is from a WinForms developer 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for some recommendations about compressing data in .NET, aside from using
Aside from the obvious heavy load on the server, is it bad to have
Aside from trying perldoc <module name> individually for any CPAN module that takes my
Aside from executing XP_CmdShell, which I have disabled in my SQL 2005 installation, what
Aside from DeployerFTP, are there any plugins that offer the ability to deploy a
Aside from scalability issues, has anyone here actually stumbled upon a web-development problem where
Aside from not deploying a Django project to the web site root directory, is
Aside from Websphere, the Sun/Oracle JVM seems to be near-ubiquitous. Do people have much
Aside from the added complexity, do you think that the inclusion of the Generics
Aside from the obvious (localhost, 127.0.0.1) does PHP (command line interface!) have a mechanism

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.