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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:40:56+00:00 2026-06-12T03:40:56+00:00

I am a beginner to JUnit and design patterns, so please pardon me. I

  • 0

I am a beginner to JUnit and design patterns, so please pardon me.

I was reading this technical webpage:

http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&sqi=2&ved=0CB4QFjAA&url=http%3A%2F%2Ftechruminations.wordpress.com%2F2011%2F05%2F30%2Fsales-tax-problem-form-thoughtworks-for-interview%2F&ei=QBVjUIHgDYWAiQefzoHoBQ&usg=AFQjCNFIBDF10v9zEMRpAIgl9Yi7DZ172w&sig2=E-Dwtx9UaU4lBbyD0j9bww

I can understand the actual coding and class organization etc. The only thing that confuses me are the two questions below related to this particular problem:

  1. It used a design pattern called “dependency injection” by using Google’s Guice, however, I found that I could get around without using this design pattern achieving the same function. I wonder using dependency injection is not a must in this problem?

  2. Since I am new to JUnit, my understanding is that he wrote test cases for cart,item and test them individually to prove the correctness. But why does he need the final “Build and Deployment” section to compile and run the test program, since I can easily do that without creating that xml file and just do right-click in Eclipse and select “run as JUnit test”.

Please give me some help on JUnit and design patterns, thank you!!

  • 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-12T03:40:58+00:00Added an answer on June 12, 2026 at 3:40 am
    1. Guice is a dependency injection framework, which is a very useful tool for managing long chains of objects and their dependencies, and for changing implementations later. It is not strictly necessary for this problem, or for any problem, but you may find it very useful in certain circumstances.

      • In the example you posted, there is only one implementor of ItemIntf, and only one implementor of CartIntf, and only one implementor of TaxCalculatorIntf. Because these are bound with Guice, you could later write another implementation of CartIntf (say, SessionBasedCart) and change which implementation your classes use just by changing that single line in the module.
      • Likewise, if Item needed an additional dependency, such as ItemCatalog, you would not need to change any of the other files. Item could simply inject ItemCatalog.
      • Finally, with a dependency injection framework, you may find that your classes are easier to test. For a class like ServiceTaxCalculator, if it calls to any external dependencies, it is very easy to write a test that passes in those dependencies (rather than letting your class use the new operator and then replacing them later).
    2. The Build and Deployment section refers to a tool called Ant, which is a way of using XML to specify build instructions and dependencies such as JUnit. Eclipse has a set of built-in tools for managing the classpath and managing dependencies on JUnit, which means that you do not need to build one of those on your own. However, if you wanted to run your tests outside of Eclipse, you may need to create a file similar to that one.

    You can read more about Apache Ant to see exactly what it can do for your project, and likewise read more about Google Guice and why dependency injection can be a good idea for some projects.

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

Sidebar

Related Questions

Beginner here See - http://www.w3schools.com/js/tryit.asp?filename=try_dom_tablerow_cells In this example, when change content is pressed, new
Beginner here. Why is this an endless loop ? for (p = 0; p
Beginner here: In this answer to my question of how to insert data into
Beginner at Django here, I've been trying to fix this for a long time
Android beginner, Can anybody guide me on this ? I do have the distance,
Beginner here so please be patient. I am having a bit of a trouble
Beginner Android and Java developer here. I have this snippet of code inside a
Anyone knows a good tutorial for a beginner in Selenium and jUnit ? I
I am beginer in unit testing. I use JUnit and Mockito. This is one
Beginner Question. Below is an example given on the Cradle CouchDB documentation: https://github.com/cloudhead/cradle What

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.