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

  • SEARCH
  • Home
  • 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 310545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:50:36+00:00 2026-05-12T07:50:36+00:00

For applications of any size, what are the drawbacks of using a Context.Current pattern?

  • 0

For applications of any size, what are the drawbacks of using a Context.Current pattern? (i.e. “Current” is a shared/static property of a “Context” class that instantiates itself the first time it’s used)

Any advantage of using this pattern over just shared / static classes/methods?

I’m asking in the context of .NET, although I guess it could apply in a variety of languages.

  • 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-12T07:50:36+00:00Added an answer on May 12, 2026 at 7:50 am

    This is a kind of singleton pattern, usually representing thread-local storage. A well-known example in the .NET world is the HttpContext.

    The most common issue is testability. Certainly not impossible, but the pattern does encourage a usage model which is not compatible with TDD, so using it requires extra vigilance. In ASP.NET MVC, we see a much improved pattern by which the context object itself is passed through each layer as an input parameter, rather than relying on the singleton storage to access that object.

    Another way to look at it is that it does not play well with other, arguably much more useful, OO patterns such as dependency injection. Most would argue you get a lot more mileage from being able to use DI than from having a convenient singleton shortcut to your current state.

    As with any singleton or global state, it also introduces a set of problems with multi-threading and concurrency. There are well-established patterns for mitigating these, but obviously any time you use a pattern which requires “mitigation” you expose yourself to a lot of risk which would otherwise not be an issue.

    There are sometimes appropriate places for singletons, but they are very few and far between. The decision to store state in a singleton should be very carefully made by an experienced team. An inexperienced team should avoid them to be on the safe side.

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

Sidebar

Related Questions

Are there any sample applications avaliable that make use of both caliburn and prism?
Are there any open source applications that provide a set of features similar to
I have created a class that I've been using as the storage for all
I have an application where users can upload video files of any size, and
In designing any desktop applications, are there any general rules on how much memory
For some time now when I am debugging Visual C++ applications and viewing any
I need to tweak some things inside Tomcat 6.0 before any web applications or
While architecting any n-tier intranet applications, do I have to consider anything about firewalls
Starting to build web applications for mobile devices (any phone). What would be the
Is there any way to make all the applications on a server use SQL

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.