dcsimg
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

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


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

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


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