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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:15:24+00:00 2026-05-29T10:15:24+00:00

Sometimes it’s very difficult to find an error in an application because of static

  • 0

Sometimes it’s very difficult to find an error in an application because of static data. Is it a good approach to use static data in OOP or is it better to avoid it?
Thanks in advance.

UPDATE:

How often are you using static classes and for what purposes?

  • 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-29T10:15:25+00:00Added an answer on May 29, 2026 at 10:15 am

    Generally speaking static methods leads to code that is hard to test since

    • we cannot know if any other class have altered a possible state,
    • we cannot easily mock or switch out a static implementation.

    There are a few valid use cases though.

    • To implement a Singleton pattern
    • To provide costructional logic (e.g., named factory methods), such as
      • Lists.newArrayList()
      • Lists.newArrayListWithExpectedSize()
        An example of the latter could be

    I would normally refrain from using static methods and let the default principle be that the existence of any static content needs to be motivated.

    As pointed out by @Louis, static variables are useful to provide single instance constants. Typically this can also apply to member variables holding objects such as a Logger.

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

Sidebar

Related Questions

Sometimes I find that preprocessor directives aren't flexible enough for my application, so I've
Sometimes I need to quickly extract some arbitrary data from XML files to put
Sometimes I get Oracle connection problems because I can't figure out which tnsnames.ora file
Sometimes coloring a logfile or other gives a good overview when looking for stuff
Sometimes FINDSTR with multiple literal search strings fails to find all matches. For example,
Sometimes when debugging with my application I encounter Contract.Requires() failing due to the condition
Sometimes my application is crashing on CFRelease(theURL); CFURLRef theURL = CFURLCreateFromFSRef( kCFAllocatorDefault, inRef );
Sometimes a query works sometimes it doesn't. I get sometimes Virtuoso S1T00 Error SR171:
Sometimes my ASP.NET application returns a value of ::1 when querying Page.Request.UserHostAddress. I can't
Sometimes i generate data that is as little as 1k. I thought it may

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.