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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:05:58+00:00 2026-06-04T12:05:58+00:00

I didn’t find a similar question, so I apologize if it already exists. In

  • 0

I didn’t find a similar question, so I apologize if it already exists.

In my system I want a number of function libraries to ease a number of tasks across the whole system. That could be validating an e-mail. There’s no reason to write the full regular expression each time if I can have a function do it, so I only need to change things and fix errors in one place.

Say I write a class called Files_Tools.

I can make it work both by dependency injecting an instance of this class into the objects that needs functions from this class. But I can also write the Files_Tools class with static functions and access them with the scope resolution operator. But as I have come to understand one of the major things about DI (dependency injection) is to avoid this kind of “global use”. So my logic tells me to go with the DI approach. Yet, it still doesn’t feel “right” that I’m doing it this way.

So my question is – What is regarded as the most correct way to create a toolset for a system? First of all, is it to make it as a class, instead of just plain functions? And then if it really is a class is the way to go, should I aim for the SRO or DI?

I understand there is probably not a definitive answer to this question, but I want to know if I’m completely off track or heading where many other coders would have done too.

Thanks in advance 🙂

  • 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-06-04T12:06:00+00:00Added an answer on June 4, 2026 at 12:06 pm

    DI makes it easier to unit test your classes and methods without dependency on the injected class… you can mock the injected object and manipulate its returns as appropriate for your tests. Scope resolution leaves you with this dependency so the tests aren’t fully isolated.

    Many of my earlier projects use static classes for such functionality, and trying to write unit tests for them 6 years on is now a real chore because I didn’t use DI.

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

Sidebar

Related Questions

I didn't find an answer to this question because I don't know if I'm
i didn't want to ask a question, but i don't have any solution at
I didn't find much in tutorials on this specific question.. So I have a
Didn't see a question similar to this, so here goes: Let's say I'm running
I didn't find an exact answer to this question so either it's a stupid
I didn't find an answer on the net and i hope this question have
I didn't find something good that helps me so I'm asking a question, sorry
I didn't want to make the title too long but this question specifically refers
I didn't notice this question on the site already and I am having a
Didn't find any explanation from google on the question, although it's possible that I

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.