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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:28:24+00:00 2026-05-25T01:28:24+00:00

I have an application which has some classes that handle some specific functions, have

  • 0

I have an application which has some classes that handle some specific functions, have a lifetime equal to the application itself, and are meant to be used in many parts of the program. For this last reason i call them Services.
For example, the Audio Service plays audio files and does many other things related to audio.

Theese classes are instantiated only once at applications startup and it does not make any sense to have more than one per type.

Since i’ve read many answers about singletons here on SO where their usage is discouraged, i went on by passing a reference to thoose services when needed.
As the project is growing i find myself with many classes which need a service reference on their constructor and in some cases even a facade to those services to avoid adding all the services references.

I think i’m doing it wrong. I think this should be a good use for static/singleton classes.

Is this a correct approach?

  • 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-25T01:28:25+00:00Added an answer on May 25, 2026 at 1:28 am

    I see one answer suggests introducing Spring. Under the covers, Spring is still passing that reference around where it is needed.

    Rather than introducing a new framework into the app, why not just use a Singleton? If it does the job and is easier to maintain than passing a service reference around, I say use it.

    If your concern about Singletons is because of their impact on testability, use Dependency Injection (the pattern, not a framework) to decrease coupling to an implementation.

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

Sidebar

Related Questions

I have a .NET application which has a custom configuration to re-construct some classes
I have an application which has a similar interface to Visual Studio, in that
I have an AJAX application which has used CSS divs to create panels on
I have a Silverlight application which has on it a Canvas. On that Canvas,
I have a C++ application which has the following structure: Class AAA: has some
I have an application which has to live as a service, I create an
I have an application which has a Projects table and a Users table. In
I have an MVC application which has a set of fields for contact details
I have an iphone application which has about 4 tabs. How do I force
I have a Windows application which has a browser in it. The Windows application

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.