can you explain java factory

Crusty

Lifer
Sep 30, 2001
12,684
2
81
Perhaps... but your question is kinda vague?

Do you know Java? I can only assume you're talking about a factory design pattern because 'java factory' doesn't yield any distinctive results, in which case it doesn't matter what language you're using because it's a logical idea.
 

Sadaiyappan

Golden Member
Nov 29, 2007
1,120
4
81
yes explain idea of factory design pattern and what it is used for.. my understanding is that it lets you create objects a different way so you can change certain code later on without affecting how you create your objects.
 
Oct 27, 2007
17,009
5
0
Read this to get a high level overview of the factory pattern. It's not really very complicated, a factory method is in charge of creating instances of an object rather than the client calling a constructor directly. There are a few reasons why you might want to do this. For example, if an object's constructor needs to do something "dangerous" like connecting to a web server (which may fail). Or if you want to grab an object of a particular abstract class, super class or interface but let the factory decide the subclass or implementing class. I'm sure the design gurus here will expand on this, but I'm fairly sure this is what you're talking about.

Like Crusty said, it's not Java-specific, it's a high-level design pattern.