Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java Language
Expertise: Beginner
Feb 26, 1998

Java OOP

Question:
What exactly is a Factory or Factory class?

Answer:
A Factory is a class that you use to create sets of related objects without explicitly invoking their constructors. You usually use a Factory class when you want to delegate resource management or tracking to another object. For example, in a program that supports multiple user interfaces, you don't want to have sets of if statements littering your code every time you instantiate a widget. Rather, you delegate the creation of widgets to a Factory class which instantiates a widget corresponding to the right user interface. That is actually what the UIManager class in the Swing Set does. Another example of a Factory in the Swing Set is the BorderFactory class which tries to reuse Border instances to conserve resources.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date