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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:55:14+00:00 2026-06-16T00:55:14+00:00

Hi I am new to String and is reading the article by Martin Fowler:

  • 0

Hi I am new to String and is reading the article by Martin Fowler: http://martinfowler.com/articles/injection.html

He gave an example of MovieLister using a MovieFinder for finding movies. In this example, he first provided the code:

class MovieLister...
    private MovieFinder finder;
    public MovieLister() {
        finder = new ColonDelimitedMovieFinder("movies1.txt");
    }
}

He pointed out that you can’t give MovieLister to your friend for reuse, unless your friend uses the same MovieFinder implementation and put the movies in the same txt file.

Yes, of course, this is NOT the way you write a component with a hope that someone can reuse it. Instead, as he progressed, you should write:

class MovieLister...
    public MovieLister(MovieFinder finder) {
        this.finder = finder;       
    }
}

Yes, that is better. Now your friend can take over your MovieLister and plug in his own code. To me, the story is complete. I miss the point why you need a Spring framework to inject the dependency. The dependency is injected to MovieLister by your friend’s code. Full stop. All the Spring setup is equivalent to simply implement the MovieFinder interface and make such a call:

MovieFinder myMovieFinder = new MyMovieFinderImpl();
MovieLister myMovieLister = new MovieLister(myMovieFinder);

Simple, easy. I know you hard code the creation of the MyMovieFinderImpl instance in your code. But what’s the point of moving this to XML but bringing so much other stuff? Since when programmers become so scared of compiling code and prefer changing XML without compiling to get everything done? I am sorry but I think I just miss the point. Every program uses dependency inject, decades ago. But in the old days, dependency is injected by programs using a library, or a DOS command line, or a GUI. Why now we need yet another way as to inject dependency?

Thank you.

Updated:

Well, many of you guys brought annotation up. In my sallow understanding of Spring, I may feel more comfortable using XML rather than annotation. At least there is a central place listing how the dependency is, in a way that is easier to understand. With annotation, no such central place. Instead, just magic happening. Wanna know what is passed in as the parameter? Go figure it out yourself and good luck. Yes, I know there are smart IDE plugins help navigate the code. But why we make one thing complicated in the first place and celebrate another thing that helps make our life easier? The truth that annotation makes code harder to browse and understand so people create IDE plugins for this is obvious enough that we may create unnecessary things in the first place, isn’t it?

  • 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-16T00:55:15+00:00Added an answer on June 16, 2026 at 12:55 am

    In the “old days” code was written as in the first example.

    Spring is a library, which you say is one of the ways it was done in the “old days”.

    Implementations were rarely specified on the command line or via a GUI. Multiple implementations of the same functionality weren’t needed as often because (a) systems were rarely as complex as they are today, (b) they didn’t need to interoperate with other systems the way they do today, and (c) deep testing was implemented far less often.

    What’s “so much other stuff”? Spring is segregated; you can bring in only what you need.

    Why did you ignore configuration via annotations?

    The purpose is to use a generic, localized, known, standard mechanism. It is ludicrous to say that “every program used dependency injection, decades ago.” I programmed decades ago, across a pretty wide swath of languages, and while we did similar things, we all had our own implementations, with varying levels of sophistication, and wildly varying levels of success.

    Is Spring necessary for DI/IoC? No, and a host of other DI frameworks attest to this. Is it a well-known, essentially-standard way of doing it? Yep.

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

Sidebar

Related Questions

I was reading this article => http://mgutz.com/2010/10/01/check_gmail_with_node_js.html . Below in the comments Shomrom says:
Crockford writes in http://javascript.crockford.com/survey.html : There are two ways to make a new array:
I was just reading this article: http://www.tutorialized.com/view/tutorial/Spring-MVC-Application-Architecture/11986 which I find great. It explains the
I'm trying to create a new string Attribute using Weka's Java API... Reading through
I was reading this http://blog.platformular.com/2012/03/20/load-google-chart-by-ajax-using-asp-net-mvc-and-jquery/ and this https://google-developers.appspot.com/chart/interactive/docs/gallery/areachart . How can I create an
I am reading a post about mobile web development and ASP.NET MVC here: http://www.hanselman.com/blog/ABetterASPNETMVCMobileDeviceCapabilitiesViewEngine.aspx
I reading articles about XSD on w3schools and here many examples. For example this:
String str = new String(Hello); Normally I have read, in many articles available on
string[] strArray = new string[10] { 21.65, 30.90, 20.42, 10.00, 14.87, 72.19, 36.00, 45.11,
String s = new String({'h','e','l','l','o'}); I received the error: 1 Invalid expression term '{'

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.