|
-
Mar 12th, 2002, 03:27 PM
#1
Thread Starter
Hyperactive Member
what exactly are "factories"?
a couple of times while just looking up stuff in the JavaDocs i came across various classes named something FACTORY, what exactly is the concept of the factory, like a stream isn't a class but a concept so i'm wondering if ne1 knows the dilly-yo behind "factories"
"There are only two things that are infinite. The universe and human stupidity... and the universe I'm not sure about." - Einstein
If you are programming in Java use www.NetBeans.org
-
Mar 13th, 2002, 12:06 AM
#2
kinda hard to explain, but here goes...
they're pretty much just ready made classes that are used to access a specific interface, so u don't have to worry about doing it yourself.
e.g the BorderFactory is made up of static classes that return a Border (interface) object, which u can then use to (suprise suprise) set the border of a GUI component
B
-
Mar 13th, 2002, 12:58 PM
#3
Thread Starter
Hyperactive Member
i think i'm getting it.... anyone else?
"There are only two things that are infinite. The universe and human stupidity... and the universe I'm not sure about." - Einstein
If you are programming in Java use www.NetBeans.org
-
Mar 13th, 2002, 03:47 PM
#4
Dazed Member
I think axion_sa pretty much summed
it up. I don't know the exact definition
but they seem to give you a handle to
a specific class or interface.
Code:
Toolkit tk = tk.getDefaultTookKit();
Image image = tk.getImage();
-
Mar 13th, 2002, 03:56 PM
#5
Addicted Member
Good question. Didn't know the answer, but I'd seen reference to them so I did a little searching. Found this in usenet:
A factory class is a class that contains a method that returns objects of another class. You use that method instead of the constructor to create the new objects. This can be useful if you have a situation where you need to choose one of several classes based on some parameter. A constructor can't do that.
cudabean
-
Mar 15th, 2002, 11:48 AM
#6
Thread Starter
Hyperactive Member
so kinda like server sockets(i think that what they're called...) where they listen for a connection and then return a connected socket instead of using a constructor?
"There are only two things that are infinite. The universe and human stupidity... and the universe I'm not sure about." - Einstein
If you are programming in Java use www.NetBeans.org
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|