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 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

Somebody must have already written a script to delete all lines from all tables
I am tasked with developing a multi lingual site using ASP.NET MVC. For static
I've been tasked with porting/refactoring a Web Application Platform that we have from ASP.NET
I've been tasked to extract data from a Domino and commit changes to it
Somebody have idea how to use all cores for calculating integration? I need to
Somebody wrote this (very terrible) function to translate a numeric value from 0-999 to
somebody knows if it's possible to set a specific line-height for three20-styled texts? thanks
Somebody mentioned BuildMaster to me lately as build management environment. http://inedo.com/buildmaster/features/all-features Does anybody have
Somebody knows a nice program for creating database models supporting Osx and Linux? If
Somebody can give me an example to do this. Suppose static variable scope is

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.