GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  J2EE  >  Java Patterns
Go To First  |  Previous Question  |  Next Question 
 Java Patterns  |  Question 16 of 20    Print  
What is Inversion Of Control and the Dependency Injection pattern?

  
Total Answers and Comments: 2 Last Update: July 13, 2009     Asked by: manish_cs00 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: PNVRKPrasad
 

Comment: Dependency Injection is more appropriate name than inversion of control.
Purpose: Achieving polymorphism more flexibly through different server classes
How: Allocating (Injecting) the actual concrete class1 (server) at run time to the class2 (client). Class1 has variations and the configuration file holds the information of which class needs to be injected. Class1 can be replaced by class1A through config file.
Ways: Injecting through class2's constructor, Setter method,..
Examples: Spring, PicoContainer, Avalon
Similar patterns: Service Locator
Final word: Most of the design patterns are there to handle polymorphism requirements. They do it in different ways. Key is to understand the underlying problem/purpose.



Above answer was rated as good by the following members:
bbwinston
January 31, 2008 16:57:57   #1  
jwhite1202 Member Since: January 2008   Contribution: 2    

RE: What is Inversion Of Control and the Dependency Injection pattern?
Inversion Of Control (IoC) and Dependency Injection (DI) are concepts generally associated with the Spring Framework. The easiest way to think of Inversion Of Control is what Rod Johnson (founder of the Spring framework) calls the Hollywood Principal "don't call us we'll call you:. IoC uses interfaces to acquire and release resources a prime example being JDBC connections. This also part of the reason Spring works so well with Object/Relational Mapping (ORM) tools such as Hibernate iBatis and TopLink.

DI is a more specific version of IoC. DI pushes application dependencies at runtime. DI comes in several flavors in Spring:
1. Setter Injection - uses Java Bean setters (and getters) to get dependencies
2. Contructor Injection - dependencies come from constructor arguments
3. Method Injection - where the container is used to implement dependencies

 
Is this answer useful? Yes | No
July 11, 2009 10:05:28   #2  
PNVRKPrasad Member Since: July 2009   Contribution: 4    

RE: What is Inversion Of Control and the Dependency Injection pattern?

Comment: Dependency Injection is more appropriate name than inversion of control.
Purpose: Achieving polymorphism more flexibly through different server classes
How: Allocating (Injecting) the actual concrete class1 (server) at run time to the class2 (client). Class1 has variations and the configuration file holds the information of which class needs to be injected. Class1 can be replaced by class1A through config file.
Ways: Injecting through class2's constructor Setter method ..
Examples: Spring PicoContainer Avalon
Similar patterns: Service Locator
Final word: Most of the design patterns are there to handle polymorphism requirements. They do it in different ways. Key is to understand the underlying problem/purpose.


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    

 Related Questions

Latest Answer : when you want to restrict the object creation of a particular call is more tahn one then use singiltion class ...
Read Answers (5) | Asked by : manepalli

Latest Answer : Yep we can make the Singleton class synchronized and non clonebale... ...
Read Answers (6) | Asked by : sunils

Latest Answer : Many interactive Web applications are composed of brittle collections of interdependent Web pages. Such applications can be hard to maintain and extend. The Front Controller pattern defines a single component that is responsible for processing application ...
Read Answers (4) | Asked by : satyanarayana

Latest Answer : Just as design patterns provide a way to communicte  concisely with desired software practices, these antipatterns provide the equivalent advantages of communicating with undesirable practices.An antipattern is a classified bad design , it is just ...
Read Answers (2) | Asked by : Kiran

Latest Answer : Creative Design Pattern is one J2EE patterns. This pattern is used for project design and building. Best ever patterns are J2EE patterns. ...
Read Answers (3) | Asked by : javajet

Latest Answer : A context object encapsulates web server specific HTTP information in more general and portable form.It is used when  * you have components and services that need access to the system information. * You want to decouple application components ...
Read Answers (1) | Asked by : enjoy

One set of Design Patterns is known as "Antipatterns." Referring to the statement above, how does an Antipattern help in designing a code solution? Choice 1 It allows code to be optimized by demonstrating ways to use bit-wise complements of integers. Choice 2 To enable an implementation of a problem to be developed as quickly as possible when a deadline is approaching Choice 3 To document and explain a code design technique that experience shows does not work well in practice
Read Answers (2) | Asked by : Teena

Latest Answer : Comment: Dependency Injection is more appropriate name than inversion of control.Purpose: Achieving polymorphism more flexibly through different server classesHow: Allocating (Injecting) the actual concrete class1 (server) at run time to the class2 ...

Latest Answer : DAO design pattern helps to hide the complex database access, and provides the developer the freedom from it. It can be used for single DB or multiple DB based on the design pattern it is implementd. If the DB of the underlying system is not subjected ...

What are the similarities between an architectural pattern and design pattern. 
Latest Answer : In Simple words, design patterns are subset of Architectural patterns.   Design patterns are proven solutions to software design issues and design patterns is applicable for software modules/components and communication between software components. ...
Read Answers (1) | Asked by : ksmiles


 Sponsored Links

 
Related Articles

Service Oriented Java Business Integration Review

Service Oriented Java Business Integration Review Introduction If you ve read through the texts which give you an introduction to SOA or Web Services you will often find them to be quite frustrating and the reason for this is because they spend too much time referencing business processes which are
 

High Level Data Link Control (HDLC)

High Level Data Link Control HDLC The High Level Data Link Control protocol was developed by the International Organization for Standardization ISO It is used for switched and non switched networks and is a bit oriented architecture The High Level Data Link Control has been accepted and used widel
 

Synchronous Data Link Control (SDLC)

Synchronous Data Link Control SDLC The SDLC or the Synchronous Data Link Control was first developed by IBM It is basically a linked layer protocol which can be used with systems network architecture or the SNA environment In this system all the functions in a network can be defined and slotted into
 

jQuery Three-color Alternating Pattern

Learning jQuery Three color Alternating Pattern There may be times when we want to apply more complex striping For example we can apply a pattern of three alternating row colors rather than just two To do so we first need to define another CSS rule for the third row We ll also reuse the odd and even
 

ERP Operation and Control

ERP Operation and Control The selection of the most suitable management system is it a difficult decision to make but once it is decided the next step is the operation and maintenance of ERP It is necessary to know well all the capacities and abilities in order to exploit the system to its fullest e
 

ERP Systems as Quality Control Support

ERP Systems as Quality Control Support For the past few years ERP systems have became one of the most powerful tools for quality control management But ERP is just an informatics system that provides support to the integrated business management mosgoogle center Goals of the Quality Control Module i
 

Java and Client Server Models

Java and Client Server Models The Role of Client Servers on the Web Client server models provide the essential mechanisms for working with the Internet In fact most of the World Wide Web is built according to this paradigm In client server models the web browsers run by millions of users are the cli
 

The Interview Snafu

How to turn someone else’s mistake to your advantage Your dream job is about to become reality. A recruiter gave you the heads up about the perfect position at Humungous Conglomerate, Inc. You went through five interviews as well as a battery of psychological tests mandated by their HR de
 

Winning a Job Interview with a Winning Resume

Does your resume unlock your potential, take your skills to the highest level and win you the interview and the job you want now? The job market today is highly competitive and even if you think you have what it takes to get an interview you won’t get over the line without a polished, prof
 

Supply Chain Management : Quality Control in Industrial Engineering

Supply Chain Quality Control in Industrial Engineering When it comes to the industrial engineering aspect of supply chain management quality control and quality assurance are two duties that must be undertaken The former refers to the process whereby measures are taken to make sure defective product
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape