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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:17:41+00:00 2026-05-11T21:17:41+00:00

Somebody tasked with creating a Core set of libraries created a set of static

  • 0

Somebody tasked with creating a “Core” set of libraries created a set of static classes providing all sorts of utilities from logging, auditing and common database access methods.

I personally think this stinks because we now have a Core set of libraries that are hard to test because I can’t mock / stub these classes or do any injection into their constructors.

I suppose I can use TypeMock to stub these out but I’d rather do it for free.

What do you think?

Edit

If you don’t think they’re hard to test could you give an example of how you would test them. These static classes instantiate other types to do their functions.

  • 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-11T21:17:41+00:00Added an answer on May 11, 2026 at 9:17 pm

    Static classes (methods) do not necessarily have to be avoided as long as they have no hidden dependencies. Of course you can pass dependencies into a static method – it just should not be stored internally and modify the behaviour of later calls.
    There should be no problem to test them in this case, too.

    But I have a bad feeling about the cases you mentioned, too. I know some of these static “wrapper” utility classes – and in most cases they really stink 🙂

    EDIT:
    Maybe I should clarify. I would use static classes/methods only for very small distinguished tasks. When static classes start to initialize dependencies they certainly should be avoided. If you can’t test these static classes they already have a too big job to do.

    In the first answer of this question are the arguments against static classes as you mentioned.

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

Sidebar

Related Questions

I've been tasked to extract data from a Domino and commit changes to it
I've been tasked with porting/refactoring a Web Application Platform that we have from ASP.NET
Somebody please tell me it is possible to recover Visual Studio source after VS
Can somebody point me to a resource that explains how to go about having
Could somebody please do a rundown of how to programmatically encrypt a config-file in
Can somebody suggest a good free tool for analyzing .Net memory dumps other than
Does somebody know how to recover a never-starting eclipse when the error org.eclipse.swt.SWTError: Item
Could somebody please name a few. I could given time, but this is for
Does somebody know a Java library which serializes a Java object hierarchy into Java
Can somebody remember what was the command to create an empty file in MSDOS

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.