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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:11:14+00:00 2026-06-01T20:11:14+00:00

I read the book Working effectivly with Legacy code . I understand the technics

  • 0

I read the book Working effectivly with Legacy code.

I understand the technics to break dependencies in Legacy code

But I want to understand how to avoid these dependencies for the first time:

1- Regarding static methods:

I understand Introduce Instance Delegator

But does it mean we should avoid static methods at all?

(when it not just a Macro for some piece of code.

Meaning it has some real logic and it’s instance independant?)

2- Global variable

I understand Introduce Static Setter,

but again – should we avoid Singelton at all?

  • 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-01T20:11:15+00:00Added an answer on June 1, 2026 at 8:11 pm

    The critisicm of static methods in the world of unit testing traditionally is the difficulting in mocking them out. I have never agreed with that as a reason for avoiding static methods (and in anticipation of those who disagree, not everyone has the luxury of using an IOC container).

    There are tools that will mock static classes, such as JustMock.

    Another, dirtier approach for mocking singletons is to have the singleton return an interface and mock out the instance on the singleton during unit testing using a private accesssor or straight reflection.

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

Sidebar

Related Questions

I recently read Michael C. Feathers' book Working effectively with legacy code and came
I want to read a book that systematically introduces dom with live examples. Any
I am not a Groovy expert, but I did read the book Groovy in
I've been working on a Cook Book App but each view ( or recipie
I'm working on the K&R book. I've read farther ahead than I've done exercises,
I'm working with an excel book containing a large number of sheets; the first
I read a book that uses infix, infixr, and infixl in the sample programs.
I read a book that write the next program in C, and convet the
I read the book Algorithm Design, chapter 1, it gave a very short description
Recently I read a book( CleanCode ) in this book, FUNCTION SHOULD DO ONE

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.