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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:38:21+00:00 2026-05-12T15:38:21+00:00

I have read the following discussions: Should private helper methods be static if they

  • 0

I have read the following discussions:

Should private helper methods be static if they can be static , and
Should all methods be static if their class has no member variables

It seems that people in general would accept static methods, but are a little bit skeptical about it, for the following 2 reasons:

  1. They are hard to test.
  2. They violate the OO principle. (They
    are functions, not methods, said a
    person.)

And the most acceptable static methods are private static ones. But then why do static methods exist at all, and in what situations they are the first priority to be adopted?

  • 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-12T15:38:22+00:00Added an answer on May 12, 2026 at 3:38 pm

    Static methods aren’t hard to test in and of themselves. The problem is that other code calling the static method is hard to test, because you can’t replace the static methods.

    I think static methods are fine either when they’re private or when they’re “utility” methods – e.g. to do string escaping. The problem comes when you use static methods for things that you want to be able to mock out or otherwise replace within tests. Factory methods can be useful too, although dependency injection is generally a better approach – again, it partly depends on whether you want to be able to replace the functionality in tests.

    As for not being “OO” – not everything you write in a generally OO language has to be “pure” OO. Sometimes the non-OO route is simply more pragmatic and leads to simpler code. Eric Lippert has a great blog post about this, which unfortunately I can’t find right now. However, there’s a comment in this post which is relevant. It talks about extension methods rather than static methods, but the principle is the same.

    Extension methods are often criticized
    as being “not OOP enough”. This seems
    to me to be putting the cart in front
    of the horse. The purpose of OOP is to
    provide guidelines for the structuring
    of large software projects written by
    teams of people who do not need to
    know the internal details of each
    other’s work in order to be
    productive. The purpose of C# is to be
    a useful programming language that
    enables our customers to be productive
    on our platforms. Clearly OOP is both
    useful and popular, and we’ve
    therefore tried to make it easy to
    program in an OOP style in C#. But the
    purpose of C# is not “to be an OOP
    language”. We evaluate features based
    on whether they are useful to our
    customers, not based on whether they
    conform strictly to some abstract
    academic ideal of what makes a
    language object-oriented. We’ll
    happily take ideas from oo,
    functional, procedural, imperative,
    declarative, whatever, so long as we
    can make a consistent, useful product
    that benefits our customers.

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

Sidebar

Related Questions

I have read this post about how to test private methods. I usually do
I have read the following properties from AD, TerminalServicesProfilePath TerminalServicesHomeDirectory TerminalServicesHomeDrive I've tried DirectoryEntry
I have got the following code from here to read an Excel file using
I have read a lot that LISP can redefine syntax on the fly, presumably
I have read about partial methods in the latest C# language specification , so
I have read (or perhaps heard from a colleague) that in .NET, TransactionScope can
I have read the following statement. The status argument given to _exit() defines the
I have read through several reviews on Amazon and some books seem outdated. I
I have read that using database keys in a URL is a bad thing
I have read on Stack Overflow some people that have converting to C#2.0 to

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.